#include <bits/stdc++.h>
using namespace std;
struct node {
  int index;
  int ff;
  bool operator<(const node& no) const {
    if (index == no.index)
      return ff > no.ff;
    else
      return index < no.index;
  }
} no[2000010];
struct ANS {
  int l, r;
  ANS() {}
} ans[2000010];
vector<ANS> v;
int main() {
  int n, k, a, b;
  scanf("%d %d", &n, &k);
  int index = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    no[index].index = a;
    no[index++].ff = 1;
    no[index].index = b;
    no[index++].ff = (-1);
  }
  sort(no, no + index);
  int l, r;
  int cnt = 0;
  int ll = 0;
  bool flag = 0;
  for (int i = 0; i < index; i++) {
    if (no[i].ff == 1) {
      cnt++;
      if (cnt == k) l = no[i].index;
    } else {
      if (cnt == k) {
        r = no[i].index;
        ans[ll].l = l, ans[ll].r = r;
        ll++;
      }
      cnt--;
    }
  }
  cout << ll << endl;
  for (int i = 0; i < ll; i++) {
    printf("%d %d\n", ans[i].l, ans[i].r);
  }
  return 0;
}
