#include <bits/stdc++.h>
using namespace std;
int n;
struct E {
  int val, dp;
} arr[2000009];
int k;
bool operator<(E a, E b) {
  if (a.val == b.val) {
    return a.dp > b.dp;
  }
  return a.val < b.val;
}
int ans1[1000009], ans2[1000009];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &arr[i].val, &arr[i + n].val);
    arr[i].dp = 1;
    arr[i + n].dp = -1;
  }
  n *= 2;
  sort(arr, arr + n);
  int num = 0;
  int itr = 0;
  for (int i = 0; i < n; i++) {
    num += arr[i].dp;
    if (arr[i].dp == 1) {
      if (num == k) {
        ans1[itr] = arr[i].val;
      }
    } else {
      if (num == k - 1) {
        ans2[itr] = arr[i].val;
        itr++;
      }
    }
  }
  cout << itr << endl;
  for (int i = 0; i < itr; i++) {
    cout << ans1[i] << " " << ans2[i] << endl;
  }
}
