#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> pairs;
  vector<pair<int, int>> result;
  for (int i = 0; i < n; i++) {
    int x;
    int y;
    scanf("%d %d", &x, &y);
    pairs.push_back(make_pair(x, -1));
    pairs.push_back(make_pair(y, 1));
  }
  int total = 0;
  int eski_total = 0;
  int bas = 0;
  int son = 0;
  sort(pairs.begin(), pairs.end());
  for (int i = 0; i < 2 * n; i++) {
    int x_temp = pairs[i].first;
    int yon = pairs[i].second;
    total += -1 * yon;
    if (eski_total < k && total >= k) {
      bas = x_temp;
    }
    if (eski_total >= k && total < k) {
      son = x_temp - 1;
      result.push_back(make_pair(bas, son));
    }
    eski_total = total;
  }
  cout << result.size() << '\n';
  for (auto x : result) {
    printf("%d %d\n", x.first, x.second + 1);
  }
  return 0;
}
