#include <bits/stdc++.h>
using namespace std;
const int_fast32_t arrsz = 2 * 10e6 + 1;
int_fast32_t minleft = 10e9 + 1;
int_fast32_t maxright = -10e9 - 1;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int_fast32_t n, k;
  cin >> n >> k;
  int_fast32_t intl;
  int_fast32_t intr;
  int count_pairs = 0;
  pair<int_fast32_t, char> *pr;
  pair<int_fast32_t, int_fast32_t> *pa;
  pr = new pair<int_fast32_t, char>[2 * n];
  pa = new pair<int_fast32_t, int_fast32_t>[2 * n];
  for (size_t int_fast8_t = 0; int_fast8_t < n; int_fast8_t++) {
    cin >> intl >> intr;
    pr[count_pairs].first = intl;
    pr[count_pairs++].second = 'l';
    pr[count_pairs].first = intr;
    pr[count_pairs++].second = 'r';
  }
  sort(pr, pr + 2 * n);
  int_fast32_t count = 0;
  int_fast32_t open;
  int_fast32_t count_pa = 0;
  for (size_t int_fast8_t = 0; int_fast8_t < 2 * n; int_fast8_t++) {
    if (count == k - 1 && pr[int_fast8_t].second == 'l') {
      open = pr[int_fast8_t].first;
    } else if (count == k && pr[int_fast8_t].second == 'r') {
      pa[count_pa].first = open;
      pa[count_pa++].second = pr[int_fast8_t].first;
    }
    if (pr[int_fast8_t].second == 'l')
      count++;
    else if (pr[int_fast8_t].second == 'r')
      count--;
  }
  cout << count_pa << endl;
  for (size_t int_fast8_t = 0; int_fast8_t < count_pa; int_fast8_t++) {
    std::cout << pa[int_fast8_t].first << " " << pa[int_fast8_t].second
              << std::endl;
  }
  return 0;
}
