#include <bits/stdc++.h>
using namespace std;
inline bool ascending(int i, int j) { return (i < j); }
inline bool descending(int i, int j) { return (i > j); }
const int MN = 2000000 + 10;
const double maxn = 1e15;
int comp(const void *a, const void *b) { return (*(int *)a - *(int *)b); }
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second > b.second;
}
pair<int, int> arr[MN];
vector<pair<int, int> > v, v1;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (__typeof(0) i = 0; i != n; i++) {
    int inp;
    scanf("%d", &inp);
    arr[i * 2] = make_pair(inp, 1);
    scanf("%d", &inp);
    arr[2 * i + 1] = make_pair(inp, -1);
  }
  sort(arr, arr + 2 * n, cmp);
  v.push_back(make_pair(0, 0));
  bool ff = 0;
  for (__typeof(0) i = 0; i != n * 2; i++) {
    if (arr[i].second == 1) {
      v.push_back(make_pair(arr[i].first, v[int(v.size()) - 1].second + 1));
    } else {
      v.push_back(make_pair(arr[i].first, v[int(v.size()) - 1].second - 1));
    }
  }
  bool flag = 0;
  int low, up;
  n *= 2;
  int i = 0;
  while (i < n) {
    if (flag && v[i].second >= k) {
      up = v[i].first;
    } else if (flag) {
      flag = 0;
      up = v[i].first;
      v1.push_back(make_pair(low, up));
    } else if (v[i].second == k) {
      flag = 1;
      low = v[i].first;
      up = v[i].first;
    }
    ++i;
  }
  if (flag) {
    up = v[i].first;
    v1.push_back(make_pair(low, up));
  }
  cout << int(v1.size()) << endl;
  for (__typeof(0) i = 0; i != int(v1.size()); i++) {
    printf("%d %d\n", v1[i].first, v1[i].second);
  }
  return 0;
}
