#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  vector<pair<long long, long long> > v;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    v.emplace_back(make_pair(l, 1));
    v.emplace_back(make_pair(r + 1, -1));
  }
  long long curr = 0, prev = -2e9;
  sort(v.begin(), v.end());
  vector<pair<long long, long long> > ans;
  for (auto i : v) {
    if (i.second == 1) {
      curr++;
      if (curr >= k and prev == -2e9) {
        prev = i.first;
      }
    } else {
      curr--;
      if (curr < k and prev != -2e9) {
        ans.emplace_back(make_pair(prev, i.first - 1));
        prev = -2e9;
      }
    }
  }
  if (curr >= k and prev != -2e9) {
    ans.emplace_back(make_pair(prev, v.back().first - 1));
  }
  cout << ans.size() << '\n';
  ;
  for (auto i : ans) {
    cout << i.first << " " << i.second << '\n';
    ;
  }
  return 0;
}
