#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << "\n"; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << ' ' << H;
  debug_out(T...);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(12);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> v;
  vector<int> ans;
  for (int i = 0, x, y; i < n; ++i) {
    cin >> x >> y;
    v.emplace_back(x, -1);
    v.emplace_back(y, +1);
  }
  sort(v.begin(), v.end());
  int balance = 0;
  bool pass = false;
  for (int i = 0; i < 2 * n; ++i) {
    balance -= v[i].second;
    if (balance == k && !pass) {
      ans.emplace_back(v[i].first);
      pass = true;
    }
    if (balance == k - 1 && pass) {
      ans.emplace_back(v[i].first);
      pass = false;
    }
  }
  cout << (int)ans.size() / 2 << "\n";
  for (int i = 0; i < (int)ans.size(); i += 2) {
    cout << ans[i] << " " << ans[i + 1] << "\n";
  }
}
