#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
struct s
{
long long num, g;
}st[10000];
bool su(s x, s y)
{
return x.g > y.g;
}
int main()
{
long long n, m, sum, m1;
cin >> n >> m;
m1 = m * 3 / 2;
for (long long i = 1; i <= n; i++)
{
cin >> st[i].num >> st[i].g;
}
sort(st + 1, st + n + 1, su);
if (st[m1].g == st[m1 + 1].g)
m1 += 1;
for (int i = 1; i < n; i++)
{
if (st[i].num > st[i + 1].num && st[i].g == st[i + 1].g)
swap(st[i].num, st[i + 1].num);
}
cout << st[m1].g << " " << m1 << endl;
for (int i = 1; i <= m1; i++)
{
cout << st[i].num << " " << st[i].g << endl;
}
return 0;
}