#include <bits/stdc++.h>
using namespace std;
struct poi {
  int x;
  int p;
} a[2000010];
bool cmp(poi xx, poi yy) {
  if (xx.x == yy.x) return xx.p < yy.p;
  return xx.x < yy.x;
}
int b[2000010];
int c[2000010];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int i, k1 = 0, x, y;
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    a[k1].x = x;
    a[k1].p = 1;
    k1++;
    a[k1].x = y;
    a[k1].p = 2;
    k1++;
  }
  int count = 0;
  k1 = -1;
  sort(a, a + 2 * n, cmp);
  for (i = 0; i < 2 * n; i++) {
    if (a[i].p == 1) {
      count++;
      if (count == k) {
        k1++;
        b[k1] = a[i].x;
      }
    }
    if (a[i].p == 2) {
      if (count == k) {
        k1++;
        b[k1] = a[i].x;
      }
      count--;
    }
  }
  printf("%d\n", (k1 + 1) / 2);
  for (i = 0; i < k1; i += 2) {
    printf("%d %d\n", b[i], b[i + 1]);
  }
  return 0;
}
