#include <bits/stdc++.h>
using namespace std;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
struct node {
  int x, y;
} f[2203456], ans[2203456];
bool cmp(node x, node y) { return x.x == y.x ? x.y > y.y : x.x < y.x; }
int main() {
  int n, k;
  cin >> n >> k;
  int tot = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    f[tot].x = a, f[tot].y = 1;
    tot++;
    f[tot].x = b, f[tot].y = -1;
    tot++;
  }
  sort(f, f + tot, cmp);
  int cnt = 0, ansi = 0, start = 0;
  for (int i = 0; i < tot; i++) {
    if (cnt == k - 1 && f[i].y == 1) {
      start = f[i].x;
    }
    if (cnt == k && f[i].y == -1) {
      ans[ansi].x = start;
      ans[ansi].y = f[i].x;
      ansi++;
    }
    cnt += f[i].y;
  }
  cout << ansi << endl;
  for (int i = 0; i < ansi; i++) {
    printf("%d %d\n", ans[i].x, ans[i].y);
  }
  return 0;
}
