#include <bits/stdc++.h>
using namespace std;
pair<int, int> Line[3000006];
int tot = 1;
int t[3000006];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    Line[tot++] = make_pair(x, -1);
    Line[tot++] = make_pair(y, 1);
  }
  sort(Line + 1, Line + tot);
  int flag1 = 0, flag2 = 0;
  vector<int> ans1;
  vector<int> ans2;
  for (int i = 1; i < tot; i++) {
    t[i] = t[i - 1] - Line[i].second;
    if (t[i] == k && t[i - 1] == k - 1) ans1.push_back(Line[i].first);
  }
  memset(t, 0, sizeof(t));
  for (int i = 1; i < tot; i++) {
    t[i] = t[i - 1] - Line[i].second;
    if (t[i] == k - 1 && t[i - 1] == k) ans2.push_back(Line[i].first);
  }
  if (ans1.size() != ans2.size()) ans2.push_back(Line[tot - 1].first);
  cout << ans1.size() << endl;
  for (int i = 0; i < ans1.size(); i++)
    cout << ans1[i] << " " << ans2[i] << endl;
}
