#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int INFv = 1e9 + 10;
const int N = 2000200;
struct point {
  int v;
  int t;
  bool operator<(const point &e) const {
    return v < e.v || v == e.v && t < e.t;
  }
} p[N];
int n, k, m;
vector<pair<pair<int, int>, int> > res;
vector<pair<int, int> > ans, ansp;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    p[2 * i - 1].v = x;
    p[2 * i - 1].t = 1;
    p[2 * i].v = y;
    p[2 * i].t = 2;
  }
  sort(p + 1, p + 1 + 2 * n);
  int cnt = 0;
  int x = 0;
  int f = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (p[i].t == 1) {
      cnt++;
      if (cnt == k) x = p[i].v, f = 1;
    } else {
      cnt--;
      if (cnt == k - 1) res.push_back({{x, p[i].v}, cnt + 1}), f = 0;
    }
  }
  if (f) res.push_back({{x, p[2 * n].v}, cnt});
  int val = INFv;
  for (int i = 0; i < res.size(); i++) val = min(val, res[i].second);
  for (int i = 0; i < res.size(); i++) {
    if (res[i].second == val)
      ans.push_back({res[i].first.first, res[i].first.second});
  }
  int l = INFv;
  int r = INFv;
  for (int i = 0; i < ans.size(); i++) {
    if (ans[i].first == r) {
      r = ans[i].second;
    } else {
      if (l != INFv) ansp.push_back({l, r});
      l = ans[i].first;
      r = ans[i].second;
    }
  }
  if (l != INFv) ansp.push_back({l, r});
  cout << ansp.size() << '\n';
  for (int i = 0; i < ansp.size(); i++)
    cout << ansp[i].first << " " << ansp[i].second << '\n';
  return 0;
}
