#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v, res;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int s, e;
    cin >> s >> e;
    v.push_back(make_pair(s, -1));
    v.push_back(make_pair(e, 1));
  }
  sort(v.begin(), v.end());
  int cnt = 0, l;
  for (int i = 0; i < v.size(); i++) {
    if (v[i].second == -1) {
      cnt++;
      if (cnt == k) l = v[i].first;
    } else {
      cnt--;
      if (cnt == k - 1) res.push_back(make_pair(l, v[i].first));
    }
  }
  cout << res.size() << "\n";
  for (int i = 0; i < res.size(); i++)
    cout << res[i].first << " " << res[i].second << "\n";
}
