#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << "[" << H << "]";
  debug_out(T...);
}
clock_t startTime;
double getCurrentTime() {
  return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
const int MOD = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= MOD;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}
template <typename t1, typename t2>
inline bool upmax(t1 &a, t2 b) {
  if (a < (t1)b) {
    a = (t1)b;
    return true;
  } else
    return false;
}
template <typename t1, typename t2>
inline bool upmin(t1 &a, t2 b) {
  if (a > (t1)b) {
    a = (t1)b;
    return true;
  } else
    return false;
}
void solve(int TC) {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > v;
  v.reserve(2 * n);
  for (int i = 0; i < n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    v.emplace_back(l, -1);
    v.emplace_back(r, 1);
  }
  sort((v).begin(), (v).end());
  vector<pair<int, int> > ans;
  int d = 0;
  int last = 0;
  for (auto [x, y] : v) {
    if (y == -1) {
      if (++d == k) last = x;
    } else {
      if (d-- == k) ans.push_back(make_pair(last, x));
    }
  }
  cout << ans.size() << endl;
  for (auto [x, y] : ans) {
    printf("%d %d\n", x, y);
  }
}
int main() {
  startTime = clock();
  int T = 1;
  for (int i = 1; i <= T; i++) {
    cerr << "Case #" << i << ":" << endl;
    solve(T);
  }
  cerr << "Time: " << getCurrentTime() << " ms" << endl;
  return 0;
}
