#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
struct node {
  int x, flag;
} a[2 * N];
bool cmp(const node a, const node b) {
  if (a.x == b.x)
    return a.flag > b.flag;
  else
    return a.x < b.x;
}
vector<pair<int, int> > ans;
int main(void) {
  int n, k, l, r;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &l, &r);
    a[2 * i].x = l;
    a[2 * i].flag = 1;
    a[2 * i + 1].x = r;
    a[2 * i + 1].flag = -1;
  }
  n *= 2;
  sort(a, a + n, cmp);
  for (int i = 1; i < n; i++) a[i].flag += a[i - 1].flag;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    if (a[i].flag >= k) {
      l = a[i].x;
      while (i < n && a[i].flag >= k) i++;
      r = a[i].x;
      ans.push_back(make_pair(l, r));
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
