#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 10;
int n, k;
struct node {
  int x;
  int y;
  node(int a = 0, int b = 0) : x(a), y(b) {}
} poi[MAXN];
vector<node> ans;
bool cmp(node a, node b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
int main() {
  int x, y, cnt, now;
  scanf("%d%d", &n, &k);
  cnt = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    poi[cnt].x = x;
    poi[cnt].y = -1;
    cnt++;
    poi[cnt].x = y;
    poi[cnt].y = 1;
    cnt++;
  }
  now = 0;
  sort(poi + 1, poi + cnt, cmp);
  int l = -1;
  int r = -1;
  int flag;
  flag = 0;
  for (int i = 1; i < cnt; i++) {
    if (poi[i].y == -1) {
      now++;
      if (now >= k && flag == 0) {
        l = poi[i].x;
        flag = 1;
      }
    } else {
      if (now >= k) r = poi[i].x;
      now--;
      if (now == k - 1 || (i == cnt - 1 && now >= k)) {
        node tmp(l, r);
        ans.push_back(tmp);
        l = -1;
        r = -1;
        flag = 0;
      }
    }
  }
  int sz = ans.size();
  printf("%d\n", sz);
  for (int i = 0; i < sz; i++) printf("%d %d\n", ans[i].x, ans[i].y);
  return 0;
}
