#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
struct segment {
  int type;
  int value;
};
struct segment ox[2000005];
bool compareox(segment a, segment b) {
  return a.value < b.value ? true : a.value > b.value ? false : a.type < b.type;
}
vector<pair<int, int> > answers;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    ox[i * 2].type = 0;
    scanf("%d", &ox[i * 2].value);
    ox[i * 2 + 1].type = 1;
    scanf("%d", &ox[i * 2 + 1].value);
  }
  sort(ox, ox + (n * 2), compareox);
  int start = -1;
  bool comparing = false;
  int value = 0;
  for (int i = 0; i < n * 2; ++i) {
    if (ox[i].type == 0) {
      value++;
      if (value == k) {
        start = ox[i].value;
      }
    } else {
      value--;
      if (value == k - 1) {
        answers.push_back(make_pair(start, ox[i].value));
      }
    }
  }
  int size = answers.size();
  printf("%d\n", size);
  for (int i = 0; i < size; ++i) {
    printf("%d %d\n", answers[i].first, answers[i].second);
  }
  return 0;
}
