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