#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool sortbysec(const pair<long long, long long>& a,
               const pair<long long, long long>& b) {
  return (a.second < b.second);
}
bool compare(const pair<int, int>& i, const pair<int, int>& j) {
  if (i.first < j.first)
    return true;
  else if (i.first > j.first)
    return false;
  return i.second > j.second;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<pair<long long, long long> > v;
  long long y = n;
  while (n--) {
    long long a, b;
    cin >> a >> b;
    v.push_back({a, 1});
    v.push_back({b, -1});
  }
  n = y;
  sort(v.begin(), v.end(), compare);
  long long c = 0, p = 0;
  long long l, r;
  vector<pair<long long, long long> > u;
  for (long long i = 0; i < v.size(); i++) {
    c += v[i].second;
    if (p == k - 1 && c == k) {
      l = v[i].first;
    } else if (p == k && c == k - 1) {
      r = v[i].first;
      u.push_back({l, r});
    }
    p = c;
  }
  if (p >= k) {
    u.push_back({l, v[n - 1].first});
  }
  cout << u.size() << "\n";
  for (long long i = 0; i < u.size(); i++) {
    cout << u[i].first << " " << u[i].second << "\n";
  }
}
int main() {
  fast();
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}
