#include <bits/stdc++.h>
using namespace std;
int N, K;
int tosum;
int begin1 = 1000000001, end1;
map<int, pair<int, int> > m;
vector<pair<int, int> > v;
int main() {
  if (fopen("cf612d.in", "r")) {
    freopen("cf612d.in", "r", stdin);
    freopen("cf612d.out", "w", stdout);
  }
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    m[a].first++;
    m[b].second++;
  }
  for (map<int, pair<int, int> >::iterator it = m.begin(); it != m.end();
       it++) {
    tosum += it->second.first;
    if (tosum >= K && begin1 == 1000000001) {
      begin1 = it->first;
    }
    tosum -= it->second.second;
    if (tosum < K && begin1 != 1000000001) {
      end1 = it->first;
      v.push_back(make_pair(begin1, end1));
      begin1 = 1000000001;
    }
  }
  printf("%u\n", v.size());
  for (int i = 0; i < v.size(); i++) {
    printf("%d %d\n", v[i].first, v[i].second);
  }
  return 0;
}
