#include <bits/stdc++.h>
using namespace std;
struct Segment {
  int l, r;
  Segment(int l, int r) : l(l), r(r) {}
  bool operator<(const Segment &s) const { return l < s.l; }
};
struct Event {
  int x;
  bool isstart;
  Event(int x, bool isstart) : x(x), isstart(isstart) {}
  bool operator<(const Event &e) const {
    return x < e.x ? 1 : e.x < x ? 0 : isstart > e.isstart;
  }
};
int main(int argc, char const *argv[]) {
  int n, k;
  scanf("%d %d\n", &n, &k);
  vector<Event> events;
  for (int i = 0; i < n; ++i) {
    int l, r;
    scanf("%d %d\n", &l, &r);
    events.push_back(Event(l, 1));
    events.push_back(Event(r, 0));
  }
  sort(events.begin(), events.end());
  int cur = 0;
  int l, r;
  vector<pair<int, int> > out;
  for (int i = 0; i < events.size(); ++i) {
    if (events[i].isstart) {
      cur++;
      if (cur == k) l = events[i].x;
    } else {
      cur--;
      if (cur == k - 1) {
        r = events[i].x;
        out.push_back(make_pair(l, r));
      }
    }
  }
  printf("%d\n", out.size());
  for (int i = 0; i < out.size(); ++i) {
    printf("%d %d\n", out[i].first, out[i].second);
  }
  return 0;
}
