#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
template <class T>
typename T::value_type arr_sum(const T& v, int n) {
  typename T::value_type sum = 0;
  for (int i = (0); i < (n); ++i) sum += v[i];
  return sum;
}
struct Sync_stdio {
  Sync_stdio() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
  }
} _sync_stdio;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<pair<int, int> > v(n);
  map<int, int> p;
  for (int i = (0); i < (n); ++i) {
    scanf("%d%d", &v[i].first, &v[i].second);
    v[i].first = 2 * v[i].first;
    v[i].second = 2 * v[i].second + 1;
    p[v[i].first] = 0;
    p[v[i].second] = 0;
  }
  vector<int> invp;
  int t = 0;
  for (auto& i : p) {
    i.second = t;
    invp.push_back(i.first);
    ++t;
  }
  for (int i = (0); i < (n); ++i) {
    v[i].first = p[v[i].first];
    v[i].second = p[v[i].second];
  }
  vector<int> s(p.size() + 1);
  for (int i = (0); i < (n); ++i) {
    ++s[v[i].first];
    --s[v[i].second];
  }
  for (int i = (1); i < (s.size()); ++i) {
    s[i] += s[i - 1];
  }
  vector<pair<int, int> > ans;
  int flag = 0;
  for (int i = (0); i < (int(s.size()) - 1); ++i) {
    if (s[i] >= k) {
      if (flag) {
        ans[int(ans.size()) - 1].second = invp[i + 1];
      } else {
        ans.push_back({invp[i], invp[i + 1]});
      }
      flag = 1;
    } else {
      flag = 0;
    }
  }
  printf("%u\n", ans.size());
  for (auto i : ans) {
    printf("%d %d\n", i.first / 2, (i.second - 1) / 2);
  }
}
