#include <bits/stdc++.h>
using namespace std;
int n, k, S[1000010], E[1000010], RH[2000020];
vector<int> vi;
inline int getIdx(const int& num) {
  return lower_bound(vi.begin(), vi.end(), num) - vi.begin();
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &S[i], &E[i]);
    vi.push_back(S[i]);
    vi.push_back(E[i]);
  }
  sort(vi.begin(), vi.end());
  vi.erase(unique(vi.begin(), vi.end()), vi.end());
  vector<int> psum(vi.size(), 0), T(vi.size(), 0);
  for (int i = 0; i < n; ++i) {
    int sIdx = getIdx(S[i]);
    int eIdx = getIdx(E[i]);
    ++T[eIdx];
    RH[sIdx] = S[i];
    RH[eIdx] = E[i];
    ++psum[sIdx];
    --psum[eIdx];
  }
  for (int i = 1; i < psum.size(); ++i) psum[i] += psum[i - 1];
  vector<pair<int, int> > vp;
  for (int i = 0; i < psum.size(); ++i) {
    if (psum[i] + T[i] >= k) vp.push_back(make_pair((RH[i]), (RH[i])));
    if (psum[i] >= k) vp.push_back(make_pair((RH[i]), (RH[i + 1])));
  }
  sort(vp.begin(), vp.end());
  if (vp.empty()) {
    puts("0");
    return 0;
  }
  vector<pair<int, int> > sol;
  int lo = vp[0].first, hi = vp[0].second;
  for (int i = 1; i < vp.size(); ++i) {
    if (vp[i - 1].second == vp[i].first)
      hi = vp[i].second;
    else {
      sol.push_back(make_pair((lo), (hi)));
      lo = vp[i].first;
      hi = vp[i].second;
    }
  }
  sol.push_back(make_pair((lo), (hi)));
  printf("%d\n", sol.size());
  for (int i = 0; i < sol.size(); ++i)
    printf("%d %d\n", sol[i].first, sol[i].second);
}
