#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v, res;
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) return a.first < b.first;
  return a.second > b.second;
}
int main() {
  int n, k, st, en;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &st, &en);
    v.push_back(make_pair(st, -1));
    v.push_back(make_pair(en, 1));
  }
  int cnt = 0;
  sort(v.begin(), v.end());
  stack<int> t;
  for (int i = 0; i < v.size(); i++) {
    if (v[i].second == -1)
      cnt++, t.push(v[i].first);
    else if (v[i].second == 1) {
      if (cnt >= k) res.push_back(make_pair(t.top(), v[i].first));
      t.pop();
      cnt--;
    }
  }
  sort(res.begin(), res.end(), cmp);
  int r = -1000000007, l = -1000000007, ans = 0;
  for (int i = 0; i < res.size(); i++) {
    if (res[i].first >= l && res[i].second <= r) continue;
    l = res[i].first, r = res[i].second;
    ans++;
  }
  cout << ans << endl;
  r = -1000000007, l = -1000000007;
  for (int i = 0; i < res.size(); i++) {
    if (res[i].first >= l && res[i].second <= r) continue;
    printf("%d %d\n", res[i].first, res[i].second);
    l = res[i].first, r = res[i].second;
  }
  return 0;
}
