#include <bits/stdc++.h>
using namespace std;
int n, m, k;
pair<int, int> p[2001001];
int A[2001001], B[2001001];
int main() {
  scanf("%d %d", &m, &k);
  for (int x, y; m--;) {
    scanf("%d %d", &x, &y);
    p[++n] = pair<int, int>(x, 0);
    p[++n] = pair<int, int>(y, 1);
  }
  sort(p + 1, p + n + 1);
  m = 0;
  int cross = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i].second == 0) {
      cross++;
      if (cross == k) A[++m] = p[i].first;
    } else {
      if (cross == k) B[m] = p[i].first;
      cross--;
    }
  }
  printf("%d\n", m);
  for (int i = 1; i <= m; i++) printf("%d %d\n", A[i], B[i]);
  return 0;
}
