#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    v.push_back(make_pair(l, -1));
    v.push_back(make_pair(r, 1));
  }
  int total = 0;
  int op = 0;
  sort(v.begin(), v.end());
  vector<pair<int, int>> ans;
  for (int i = 0; i < v.size(); i++) {
    if (total == k - 1 && v[i].second == -1) {
      op = v[i].first;
    }
    if (total == k && v[i].second == 1) {
      ans.push_back(make_pair(op, v[i].first));
    }
    total -= v[i].second;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
