#include <bits/stdc++.h>
using namespace std;
int N, K, l, r, c;
vector<int> ans;
vector<pair<int, int>> e;
int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < (N); i++) {
    scanf("%d %d", &l, &r);
    e.push_back({l, 1}), e.push_back({r + 1, -1});
  }
  sort(e.begin(), e.end());
  for (int i = 0; i < ((int)e.size()); i++) {
    int rs = i;
    while (i + 1 < (int)e.size() && e[i].first == e[i + 1].first) i++;
    int re = i, v = e[i].first, oldc = c;
    for (int j = rs; j <= re; j++)
      if (e[j].second == -1) c--;
    if (oldc >= K && c < K) ans.push_back(v - 1);
    oldc = c;
    for (int j = rs; j <= re; j++)
      if (e[j].second == 1) c++;
    if (oldc < K && c >= K) ans.push_back(v);
  }
  printf("%d\n", (int)ans.size() / 2);
  for (int i = 0; i < (int)ans.size(); i += 2) {
    printf("%d %d\n", ans[i], ans[i + 1]);
  }
  return 0;
}
