#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, tmp1, tmp2;
  cin >> n >> k;
  vector<pair<int, int>> events = vector<pair<int, int>>(n);
  vector<int> left;
  vector<int> right;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &tmp1, &tmp2);
    events.push_back(make_pair(tmp1, -1));
    events.push_back(make_pair(tmp2, 1));
  }
  sort(events.begin(), events.end());
  int balance = 0;
  int i = 1;
  for (auto it = events.begin(); it != events.end(); it++) {
    if (balance == k - 1 && (*it).second == -1) left.push_back((*it).first);
    if (balance == k && (*it).second == 1) right.push_back((*it).first);
    balance -= (*it).second;
  }
  cout << left.size() << endl;
  for (int i = 0; i < left.size(); i++) {
    fprintf(stdout, "%d %d \n", left[i], right[i]);
  }
  return 0;
}
