#include <bits/stdc++.h>
using namespace std;
void faster() {
  if (0) {
    freopen(
        "input"
        ".in",
        "r", stdin);
    freopen(
        "input"
        ".out",
        "w", stdout);
  }
}
int n, k, l, r;
map<double, double> ma;
vector<pair<int, int> > m;
int main() {
  faster();
  scanf("%d %d", &n, &k);
  for (int i = 0; i < int(n); i++) {
    scanf("%d %d", &l, &r);
    ma[l]++;
    ma[r + 0.5]--;
  }
  int lf = 0;
  for (decltype(ma.begin()) it = ma.begin(); it != ma.end(); it++) {
    ma[it->first] += lf;
    lf = it->second;
  }
  for (decltype(ma.begin()) it = ma.begin(); it != ma.end(); it++) {
    int f = it->first, s = it->second;
    if (s >= k) {
      while (it != ma.end() && s >= k) {
        it++;
        s = it->second;
      }
      m.push_back({f, it->first - 0.5});
    }
  }
  printf("%d\n", (int)m.size());
  for (int i = 0; i < int(m.size()); i++)
    printf("%d %d\n", m[i].first, m[i].second);
  return 0;
}
