#include <bits/stdc++.h>
using namespace std;
void print_vector(vector<int> v);
void print_array(int* array, int start, int end);
int n, k;
vector<pair<int, int> > events;
int x, y;
vector<pair<int, int> > ans, ans2;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  scanf("%d", &n), scanf("%d", &k);
  for (int i = (0), _b = (n); i < _b; i++) {
    scanf("%d", &x), scanf("%d", &y);
    events.push_back(pair<int, int>(x, -1));
    events.push_back(pair<int, int>(y, 1));
  }
  sort((events).begin(), (events).end());
  int c = 0;
  bool yup = false;
  int start = -1;
  queue<pair<int, int> > q;
  for (int i = (0), _b = ((int)(events).size()); i < _b; i++) q.push(events[i]);
  while (!q.empty()) {
    pair<int, int> f = q.front();
    int cnt = 1;
    q.pop();
    while (!q.empty() && f == q.front()) {
      q.pop();
      cnt++;
    }
    c += -1 * f.second * cnt;
    if (yup && c < k) {
      yup = false;
      ans.push_back(pair<int, int>(start, f.first));
    } else if (!yup && c >= k) {
      yup = true;
      start = f.first;
    }
  }
  if ((int)(ans).size() == 0) {
    printf("0\n");
    return 0;
  }
  int ca = ans[0].first, cb = ans[0].second;
  for (int i = (1), _b = ((int)(ans).size()); i < _b; i++) {
    if (ans[i].first > cb) {
      ans2.push_back(pair<int, int>(ca, cb));
      ca = ans[i].first;
      cb = ans[i].second;
    } else {
      cb = ans[i].second;
    }
  }
  ans2.push_back(pair<int, int>(ca, cb));
  printf("%d\n", (int)(ans2).size());
  for (int i = (0), _b = ((int)(ans2).size()); i < _b; i++) {
    printf("%d %d\n", ans2[i].first, ans2[i].second);
  }
  return 0;
}
void print_array(int* array, int start, int end) {
  printf("[");
  for (int i = (start), _b = (end); i < _b; i++) {
    printf("%d ", array[i]);
  }
  printf("]");
  printf("\n");
}
void print_vector(vector<int> v) {
  printf("[");
  for (int i = (0), _b = (v.size()); i < _b; i++) {
    printf("%d ", v[i]);
  }
  printf("]");
  printf("\n");
}
