#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > e;
  int l, r;
  for (int i = 0; i < n; ++i) {
    cin >> l >> r;
    e.push_back({l, -1});
    e.push_back({r, 1});
  }
  sort(e.begin(), e.end());
  vector<pair<int, int> > min;
  int count = 0;
  for (int i = 0; i < 2 * n; ++i) {
    if (e[i].second == -1) {
      count++;
      if (count == k) l = e[i].first;
    } else {
      count--;
      if (count == k - 1) {
        min.push_back({l, e[i].first});
      }
    }
  }
  cout << min.size() << endl;
  for (int i = 0; i < min.size(); ++i)
    cout << min[i].first << " " << min[i].second << endl;
  return 0;
}
