#include <bits/stdc++.h>
using namespace std;
const long long int hell = 1000000007;
const long long int maxn = 1e6 + 5;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  vector<pair<long long int, long long int> > v, ans;
  for (long long int i = 0; i < n; i++) {
    long long int l, r;
    cin >> l >> r;
    v.push_back({l, 0});
    v.push_back({r, 1});
  }
  sort((v).begin(), (v).end());
  long long int sum = 0, last;
  for (long long int i = 0; i < (long long int)((v).size()); i++) {
    if (v[i].second) {
      --sum;
      if (sum == k - 1) {
        ans.push_back({last, v[i].first});
      }
    } else {
      sum++;
      if (sum == k) {
        last = v[i].first;
      }
    }
  }
  cout << (long long int)((ans).size()) << '\n';
  for (auto to : ans) {
    cout << to.first << ' ' << to.second << '\n';
  }
}
