#include <bits/stdc++.h>
using namespace std;
int a[1000100][2];
int b[1000100 * 3], tmp[1000100 * 3], vis[1000100 * 3];
int bs(int x, int n) {
  int mi = 0, ma = n - 1, mid;
  while (mi <= ma) {
    mid = mi + (ma - mi) / 2;
    if (tmp[mid] == x) return mid;
    if (tmp[mid] < x)
      mi = mid + 1;
    else
      ma = mid - 1;
  }
}
vector<pair<int, int> > vec;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &b[i], &b[i + n]);
    b[i] *= 2;
    b[i + n] *= 2;
    b[i + 2 * n] = b[i + n] + 1;
    a[i][0] = b[i];
    a[i][1] = b[i + n];
  }
  sort(b, b + 3 * n);
  int num = 0;
  tmp[num++] = b[0];
  for (int i = 1; i < 3 * n; i++) {
    if (b[i] != b[i - 1]) tmp[num++] = b[i];
  }
  for (int i = 0; i < n; i++) {
    int l = bs(a[i][0], num), r = bs(a[i][1] + 1, num);
    vis[l]++;
    vis[r]--;
  }
  int now = 0;
  int left = 0, right = -1;
  for (int i = 0; i < num; i++) {
    now += vis[i];
    if (now >= k) {
      right = i;
    } else {
      if (left <= right)
        vec.push_back(make_pair(tmp[left] / 2, tmp[right] / 2));
      left = i + 1;
    }
  }
  if (left <= right) vec.push_back(make_pair(tmp[left] / 2, tmp[right] / 2));
  printf("%d\n", vec.size());
  for (int i = 0; i < vec.size(); i++) {
    printf("%d %d\n", vec[i].first, vec[i].second);
  }
  return 0;
}
