#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
template <class T>
inline void gmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline void gmin(T &a, T b) {
  if (b < a) a = b;
}
using namespace std;
const int N = 1e6 + 10, M = 2e6 + 10, Z = 1e9 + 7, maxint = 2147483647,
          ms1 = 16843009, ms31 = 522133279, ms63 = 1061109567,
          ms127 = 2139062143;
const double PI = acos(-1.0), eps = 1e-8;
void fre() {
  freopen("/Users/luras/Desktop/in.txt", "r", stdin);
  freopen("/Users/luras/Desktop/out.txt", "w", stdout);
}
const int INF = 1e9;
int casenum, casei;
struct A {
  int x, y;
} a[N], ans[N];
map<int, int> mop;
map<int, int>::iterator it;
int mop2[N * 2];
int n, k, t, num;
int e[N * 4];
int flag;
int cmp(A a, A b) { return a.x < b.x; }
int main() {
  while (~scanf("%d%d", &n, &k)) {
    mop.clear();
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &a[i].x, &a[i].y);
      mop[a[i].x];
      mop[a[i].y];
    }
    t = 0;
    for (it = mop.begin(); it != mop.end(); it++) {
      t += 2;
      mop[it->first] = t;
      mop2[t >> 1] = it->first;
    }
    memset(e, 0, sizeof(e));
    for (int i = 1; i <= n; i++) {
      e[mop[a[i].x]]++;
      e[mop[a[i].y] + 1]--;
    }
    for (int i = 1; i <= t; i++) {
      e[i] += e[i - 1];
    }
    flag = 0;
    num = 0;
    for (int i = 1; i <= t; i++) {
      if (e[i] >= k) {
        if (flag == 0) {
          flag = 1;
          ans[++num].x = mop2[i >> 1];
          ans[num].y = mop2[i >> 1];
        } else {
          ans[num].y = mop2[i >> 1];
        }
      } else {
        flag = 0;
      }
    }
    printf("%d\n", num);
    sort(ans + 1, ans + num + 1, cmp);
    for (int i = 1; i <= num; i++) {
      printf("%d %d\n", ans[i].x, ans[i].y);
    }
  }
  return 0;
}
