#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> E(2 * n);
  for (int i = 0; i < (n); i++) {
    cin >> E[2 * i].first >> E[2 * i + 1].first;
    E[2 * i].second = 1;
    E[2 * i + 1].second = -1;
  }
  sort(E.begin(), E.end(), [](pair<int, int> p1, pair<int, int> p2) -> bool {
    if (p1.first != p2.first) return p1.first < p2.first;
    return p2.second < p1.second;
  });
  vector<int> res{};
  int cnt = 0;
  int next = 0;
  int lasttime = -1000000005;
  int ent = 0;
  int lastOver = 0;
  while (next < 2 * n) {
    int initTime = E[next].first;
    if (E[next].second == -1) {
      while (E[next].second == -1 && E[next].first == initTime) {
        cnt--;
        next++;
      }
      if (cnt < k && res.size() % 2 == 1) {
        res.push_back(E[next - 1].first);
      }
    } else {
      while (E[next].second == 1 && E[next].first == initTime) {
        cnt++;
        next++;
      }
      if (cnt >= k && res.size() % 2 == 0) {
        res.push_back(E[next - 1].first);
      }
    }
  }
  cout << res.size() / 2 << endl;
  for (int i = 0; i < res.size() / 2; i++) {
    cout << res[2 * i] << " " << res[2 * i + 1] << endl;
  }
}
