#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 6;
const int MAXK = MAXN;
const int MAXABSLR = 1e9 + 9;
int n, k;
int l[MAXN], r[MAXN];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d%d", l + i, r + i);
  vector<pair<int, int> > pnt;
  for (int i = 0; i < n; ++i)
    pnt.push_back(pair<int, int>(l[i], 0)),
        pnt.push_back(pair<int, int>(r[i], 1));
  sort(pnt.begin(), pnt.end());
  int cur = 0;
  vector<int> jnt;
  for (int i = 0; i < 2 * n; ++i) {
    int prev = cur;
    if (pnt[i].second == 0)
      ++cur;
    else
      --cur;
    if (prev == k - 1 and cur == k) {
      jnt.push_back(pnt[i].first);
    }
    if (prev == k and cur == k - 1) {
      jnt.push_back(pnt[i].first);
    }
  }
  vector<pair<int, int> > ans;
  for (int i = 0; i < jnt.size();) {
    int j = i + 1;
    while (j + 1 < jnt.size() and jnt[j] >= jnt[j + 1]) j = j + 2;
    ans.push_back(pair<int, int>(jnt[i], jnt[j]));
    i = j + 1;
  }
  printf("%d\n", (int)ans.size());
  for (pair<int, int> &p : ans) printf("%d %d\n", p.first, p.second);
  return 0;
}
