#include <bits/stdc++.h>
struct punct {
  int x, tip;
  inline bool operator<(const punct &b) const {
    if (x == b.x) return tip < b.tip;
    return x < b.x;
  }
};
std::vector<punct> intervale, rasp;
int main() {
  int n, k;
  scanf("%d %d ", &n, &k);
  for (int i = 1; i <= n; i++) {
    int st, dr;
    scanf("%d %d ", &st, &dr);
    punct a;
    a.tip = -1;
    a.x = st;
    intervale.push_back(a);
    a.tip = 1;
    a.x = dr;
    intervale.push_back(a);
  }
  std::sort(intervale.begin(), intervale.end());
  int X = 0;
  for (int i = 0; i < intervale.size(); i++) {
    int op;
    if (X == k - 1 && intervale[i].tip == -1) {
      op = intervale[i].x;
    }
    if (X == k && intervale[i].tip == 1) {
      punct a;
      a.tip = intervale[i].x;
      a.x = op;
      rasp.push_back(a);
    }
    X -= intervale[i].tip;
  }
  printf("%d\n", rasp.size());
  for (int i = 0; i < rasp.size(); i++) {
    printf("%d %d\n", rasp[i].x, rasp[i].tip);
  }
}
