#include <bits/stdc++.h>
int main() {
  const char begin = 0, end = 1;
  int n, k, m, a, b, l, r;
  std::scanf("%d%d", &n, &k);
  std::vector<std::pair<int, char> > A(2 * n);
  std::vector<std::pair<int, int> > res;
  for (int i = 0; i < n; i++) {
    std::scanf("%d%d", &a, &b);
    A[2 * i].first = a;
    A[2 * i].second = begin;
    A[2 * i + 1].first = b;
    A[2 * i + 1].second = end;
  }
  std::sort(A.begin(), A.end());
  int current = 0, prev_beg;
  for (int i = 0; i < 2 * n; i++) {
    if (A[i].second == begin) {
      current += 1;
      if (current == k) prev_beg = A[i].first;
    } else {
      if (current == k) {
        res.push_back(std::make_pair(prev_beg, A[i].first));
      }
      current -= 1;
    }
  }
  std::printf("%d\n", res.size());
  for (int i = 0; i < res.size(); i++)
    std::printf("%d %d\n", res[i].first, res[i].second);
  return 0;
}
