#include <bits/stdc++.h>
using namespace std;
int x[2000000], dif[2000000], cid[2000000];
int N, K;
bool cmp(int a, int b) {
  if (x[a] == x[b]) return dif[a] > dif[b];
  return x[a] < x[b];
}
int l[2000000], r[2000000];
int C;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> x[2 * i] >> x[2 * i + 1];
    dif[2 * i] = 1;
    dif[2 * i + 1] = -1;
  }
  for (int i = 0; i < 2 * N; i++) cid[i] = i;
  sort(cid, cid + 2 * N, cmp);
  int start = -1000000001;
  int cur = 0;
  for (int i = 0; i < 2 * N; i++) {
    cur += dif[cid[i]];
    if (i == 2 * N - 1 || x[cid[i]] != x[cid[i + 1]] ||
        dif[cid[i]] != dif[cid[i + 1]]) {
      if (start == -1000000001 && cur >= K)
        start = x[cid[i]];
      else if (start != -1000000001 && cur < K) {
        l[C] = start, r[C] = x[cid[i]];
        C++;
        start = -1000000001;
      }
    }
  }
  cout << C << '\n';
  for (int i = 0; i < C; i++) cout << l[i] << ' ' << r[i] << '\n';
}
