#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
vector<pair<int, int> >::iterator it;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int a, b;
  vector<pair<int, int> > ans;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    v.push_back(make_pair(a, -1));
    v.push_back(make_pair(b, 1));
  }
  sort(v.begin(), v.end());
  int bal = 0, e = 0;
  a = INT_MAX;
  for (it = v.begin(); it != v.end(); it++) {
    bal -= it->second;
    if (bal >= k and a == INT_MAX)
      a = it->first;
    else if (bal < k and a != INT_MAX) {
      e++;
      ans.push_back(make_pair(a, it->first));
      a = INT_MAX;
    }
  }
  printf("%d\n", e);
  for (it = ans.begin(); it != ans.end(); it++)
    printf("%d %d\n", it->first, it->second);
}
