#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    seg;
stack<int> out;
int a;
pair<int, int> temp;
pair<int, int> out1[1000005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  int l, r, i, sum = 0, flag = 0, start, end, countr = 0;
  for (i = 0; i < n; i++) {
    cin >> l >> r;
    seg.push(make_pair(l, 1));
    seg.push(make_pair(r, 2));
  }
  while (!seg.empty()) {
    temp = seg.top();
    seg.pop();
    if (temp.second == 1)
      sum++;
    else
      sum--;
    if (sum == k && temp.second == 1) {
      start = temp.first;
      flag = 1;
    } else if (sum == k - 1 && temp.second == 2) {
      flag = 0;
      end = temp.first;
      out1[countr] = make_pair(start, end);
      countr++;
    }
  }
  cout << countr << '\n';
  for (i = 0; i < countr; i++)
    cout << out1[i].first << " " << out1[i].second << '\n';
  return 0;
}
