#include <bits/stdc++.h>
using namespace std;
const int N = 1000006;
pair<int, int> point[N + N];
vector<pair<int, int> > seg, ans;
bool nishat(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;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    point[i * 2] = make_pair(a, 1);
    point[i * 2 + 1] = make_pair(b, -1);
  }
  sort(point, point + 2 * n, nishat);
  int left = point[0].first, right = point[0].first, cnt = 1;
  for (int i = 1; i < 2 * n; i++) {
    if (cnt >= k) {
      seg.push_back(make_pair(left, point[i].first));
      left = point[i].first;
    } else {
      left = point[i].first;
    }
    if (point[i].second == -1)
      cnt--;
    else
      cnt++;
  }
  if ((int)seg.size() > 0) {
    for (int i = 0, j; i < (int)seg.size();) {
      for (j = i + 1; j < (int)seg.size(); ++j) {
        if (seg[j].first != seg[j - 1].second) {
          break;
        }
      }
      j--;
      ans.push_back(make_pair(seg[i].first, seg[j].second));
      i = j + 1;
    }
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); ++i) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
}
