#include <bits/stdc++.h>
struct Point {
  int xx;
  bool is_left;
  int number;
};
struct comp {
  bool operator()(const Point& first, const Point& second) const {
    if (first.xx != second.xx) {
      return first.xx < second.xx;
    } else if (first.is_left != second.is_left) {
      return first.is_left;
    } else {
      return first.number < second.number;
    }
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, k;
  std::cin >> n >> k;
  std::vector<Point> points;
  for (int i = 0; i < n; ++i) {
    int l, r;
    std::cin >> l >> r;
    points.push_back({l, true, i});
    points.push_back({r, false, i});
  }
  std::sort(points.begin(), points.end(), comp());
  std::vector<std::pair<int, int>> ans;
  int covered = 0;
  bool flag = false;
  int left, right;
  for (const auto& point : points) {
    if (point.is_left) {
      ++covered;
    } else {
      --covered;
    }
    if (covered == k && !flag) {
      flag = true;
      left = point.xx;
    } else if (covered < k && flag) {
      flag = false;
      right = point.xx;
      ans.push_back({left, right});
    }
  }
  std::cout << ans.size() << '\n';
  if (!ans.empty()) {
    for (const auto& elem : ans) {
      std::cout << elem.first << " " << elem.second << '\n';
    }
  }
  return 0;
}
