#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
struct point_t {
  int pos;
  int begin;
  bool operator<(const point_t& b) const { return pos < b.pos; }
};
map<int, int> points_s;
map<int, int> points_e;
map<int, int> single_point;
vector<pair<int, int> > res;
pair<int, int> tmp = {-1, -1};
void p_begin(int p) { tmp.first = p; }
void p_end(int p) {
  tmp.second = p;
  res.push_back(tmp);
}
map<int, int> really_point;
vector<point_t> ps;
struct ppp {
  int pos, open, close;
};
vector<ppp> def;
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    ps.push_back({a, 1});
    ps.push_back({b, 0});
  }
  sort(ps.begin(), ps.end());
  for (int i = 0; i < ps.size(); i++) {
    int start_pos = ps[i].pos;
    int open = 0, closed = 0;
    while (i < ps.size() && ps[i].pos == start_pos) {
      if (ps[i].begin == 1)
        open++;
      else
        closed++;
      i++;
    }
    i--;
    def.push_back({start_pos, open, closed});
  }
  int CNT = 0;
  for (ppp point : def) {
    int pos = point.pos;
    int old_cnt = CNT;
    int att_cnt = CNT + point.open;
    int new_cnt = att_cnt - point.close;
    CNT = new_cnt;
    if (old_cnt < k && new_cnt >= k)
      p_begin(pos);
    else if (old_cnt >= k && new_cnt < k)
      p_end(pos);
    else if (old_cnt < k && new_cnt < k && att_cnt >= k)
      res.push_back({pos, pos});
  }
  cout << res.size() << "\n";
  for (pair<int, int> p : res) cout << p.first << " " << p.second << "\n";
  return 0;
}
