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