#include <bits/stdc++.h>
using namespace std;
struct node {
  int d, sign;
} e[2 * 1010000];
bool cmp(node q, node qq) {
  if (q.d == qq.d) return q.sign < qq.sign;
  return q.d < qq.d;
}
int lpos[1010000];
int rpos[1010000];
int main() {
  int cnt, n, k, l, r, le;
  scanf("%d %d", &n, &k);
  le = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &l, &r);
    e[le].d = l;
    e[le++].sign = 0;
    e[le].d = r;
    e[le++].sign = 1;
  }
  sort(e, e + le, cmp);
  int num = 0;
  cnt = 0;
  for (int i = 0; i < le; i++) {
    if (!e[i].sign) {
      cnt++;
      if (cnt == k) lpos[num] = e[i].d;
    } else {
      cnt--;
      if (cnt == (k - 1)) rpos[num++] = e[i].d;
    }
  }
  printf("%d\n", num);
  for (int i = 0; i < num; i++) printf("%d %d\n", lpos[i], rpos[i]);
}
