#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 9e18;
const int MX = 2e5 + 5;
const long double PI = acos((long double)-1);
const int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};
void setIO(string name = "") {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if ((int)(name).size()) {
    freopen((name + ".in").c_str(), "r", stdin);
    freopen((name + ".out").c_str(), "w", stdout);
  }
}
int main() {
  setIO();
  int n, k;
  cin >> n >> k;
  map<long double, int> f;
  for (int i = (0); i < (n); i++) {
    int a, b;
    cin >> a >> b;
    f[a]++;
    f[b] = f[b];
    f[b + 0.5]--;
  }
  int s = 0, r = MOD, l = MOD;
  f[MOD] = 0;
  vector<pair<int, int>> ans;
  for (auto it : f) {
    s += it.second;
    if (s >= k) {
      if (l == MOD) l = it.first;
      r = it.first;
    } else {
      if (r != MOD) {
        ans.push_back({l, r});
        l = r = MOD;
      }
    }
  }
  cout << (int)(ans).size() << "\n";
  for (auto it : ans) cout << it.first << " " << it.second << "\n";
}
