#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<pair<int, int> > v;
vector<pair<int, int> > ans;
int l;
int cnt;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    int l1, r1;
    scanf("%d%d", &l1, &r1);
    v.push_back(make_pair(l1, -1));
    v.push_back(make_pair(r1, 1));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < 2 * n; i++) {
    cnt -= v[i].second;
    if (v[i].second == -1 && cnt == k) l = v[i].first;
    if (v[i].second == 1 && cnt == k - 1)
      ans.push_back(make_pair(l, v[i].first));
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << ' ' << ans[i].second;
    puts("");
  }
  return 0;
}
