#include <bits/stdc++.h>
using namespace std;
struct node {
  int val;
  int type;
  node(int v, int t) : val(v), type(t) {}
};
bool cmp(node a, node b) {
  if (a.val == b.val) {
    return a.type > b.type;
  }
  return a.val < b.val;
}
int n, k;
vector<node> x;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    x.push_back(node(a, 1));
    x.push_back(node(b, -1));
  }
  sort(x.begin(), x.end(), cmp);
  int cnt = 0, prev = -1, ans = 0;
  bool flag = false;
  vector<pair<int, int> > rec;
  for (auto i : x) {
    cnt += i.type;
    if (flag == false && cnt >= k) {
      flag = true;
      prev = i.val;
    }
    if (flag && cnt < k) {
      flag = false;
      rec.push_back(make_pair(prev, i.val));
      ans++;
    }
  }
  cout << ans << endl;
  for (auto i : rec) cout << i.first << " " << i.second << endl;
}
