#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    int r, l;
    scanf("%d %d", &l, &r);
    v.push_back({l, 0});
    v.push_back({r, 1});
  }
  sort(v.begin(), v.end());
  vector<pair<int, int> > ans;
  bool op = false;
  int cnt = 0, from;
  for (int i = 0; i < v.size(); i++) {
    int c = v[i].first, t = v[i].second;
    if (t == 0) {
      cnt++;
      if (cnt == k) {
        op = true;
        from = c;
      }
    } else {
      if (cnt == k) {
        op = false;
        ans.push_back({from, c});
      }
      cnt--;
    }
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
}
