#include <bits/stdc++.h>
struct point {
  int x, l;
} pp[1000000 * 2];
int qq[1000000 * 2], sk;
int pcompare(const void *a, const void *b) {
  struct point *pa = (struct point *)a;
  struct point *pb = (struct point *)b;
  return pa->x != pb->x ? pa->x - pb->x : pb->l - pa->l;
}
void sort(struct point *pp, int n) {
  int i;
  srand(time(NULL));
  for (i = n - 1; i >= 0; i--) {
    struct point tmp;
    int j = rand() % (i + 1);
    tmp = pp[i], pp[i] = pp[j], pp[j] = tmp;
  }
  qsort(pp, n, sizeof *pp, pcompare);
}
void sweep(struct point *pp, int n, int k) {
  int d, i;
  d = 0;
  for (i = 0; i <= n; i++)
    if (pp[i].l) {
      d++;
      if (d == k) qq[sk++] = pp[i].x;
    } else {
      d--;
      if (d == k - 1) qq[sk++] = pp[i].x;
    }
  printf("%d\n", sk / 2);
  for (i = 0; i < sk; i++) printf("%d%c", qq[i], i % 2 == 0 ? ' ' : '\n');
}
int main() {
  int n, k, i;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    pp[i * 2].x = l, pp[i * 2].l = 1;
    pp[i * 2 + 1].x = r, pp[i * 2 + 1].l = 0;
  }
  sort(pp, n * 2);
  sk = 0;
  sweep(pp, n * 2, k);
  return 0;
}
