#include <bits/stdc++.h>
using namespace std;
const char el = '\n';
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  map<long long, pair<int, int> > m{};
  for (int t = 0; t < n; ++t) {
    long long start;
    long long end;
    cin >> start >> end;
    ++m[start].first;
    ++m[end].second;
  }
  int coveredsum = 0;
  long long currstart;
  vector<pair<long long, long long> > segs{};
  for (auto pr : m) {
    long long x = pr.first;
    int numbegins = pr.second.first;
    int numends = pr.second.second;
    if (numbegins > 0) {
      if (coveredsum < k && coveredsum + numbegins >= k) {
        currstart = x;
      } else {
      }
      coveredsum += numbegins;
    }
    if (numends > 0) {
      if (coveredsum >= k && coveredsum - numends < k) {
        segs.push_back({currstart, x});
      } else {
      }
      coveredsum -= numends;
    }
  }
  cout << segs.size() << el;
  for (auto seg : segs) cout << seg.first << " " << seg.second << el;
}
