#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 5;
struct T {
  int l, r, i;
  bool operator<(T const& other) {
    return (l == other.l ? r < other.r : l < other.l);
  }
};
int con[MAX][2];
pair<int, int> num[2 * MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, l, r;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    num[i * 2] = {l, 1};
    num[i * 2 + 1] = {r, 2};
  }
  sort(num, num + 2 * n);
  int c = 0, a = 0;
  for (int i = 0; i < 2 * n; i++) {
    bool go = true;
    if (num[i].second == 1)
      a++;
    else
      go = false, a--;
    if (a == k && go) con[c][0] = num[i].first;
    if (a == k - 1 && !go) con[c][1] = num[i].first, c++;
  }
  cout << c << endl;
  for (int i = 0; i < c; i++) cout << con[i][0] << " " << con[i][1] << endl;
}
