#include <bits/stdc++.h>
using i64 = long long;
#ifdef DEBUG
#include "debug.h"
#else
#define debug(...) void(23)
#endif
std::vector<std::pair<int, int>> ans;
void solve(std::vector<std::array<int, 4>>& v, int k) {
// debug(v, k, ans);
int n = int(v.size());
if (k == 0) {
if (n == 0) {
for (auto[x, y] : ans) {
std::cout << x << ' ' << y << '\n';
}
exit(0);
}
return;
}
if (n == 0) {
ans.emplace_back(1, 1);
solve(v, k - 1);
return;
}
if (k == 1) {
int px = 0, py = 0;
for (auto[a, b, c, d] : v) {
px = std::max(px, a);
py = std::max(py, b);
}
bool good = true;
for (auto[a, b, c, d] : v) {
good &= a <= px && px < c && b <= py && py < d;
}
if (good) {
ans.emplace_back(px, py);
std::vector<std::array<int, 4>> nv;
solve(nv, k - 1);
}
return;
}
int xl = 0, xr = int(1E9), yl = 0, yr = int(1E9);
for (auto[a, b, c, d] : v) {
xl = std::max(xl, a);
xr = std::min(xr, c - 1);
yl = std::max(yl, b);
yr = std::min(yr, d - 1);
}
for (auto px : {xl, xr}) {
for (auto py : {yl, yr}) {
std::vector<std::array<int, 4>> nv;
for (auto[a, b, c, d] : v) {
if (!(a <= px && px < c && b <= py && py < d)) {
nv.push_back({a, b, c, d});
}
}
ans.emplace_back(px, py);
solve(nv, k - 1);
ans.pop_back();
}
}
return;
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, K;
std::cin >> N >> K;
std::vector<std::array<int, 4>> A(N);
for (int i = 0; i < N; ++i) {
std::cin >> A[i][0] >> A[i][1] >> A[i][2] >> A[i][3];
A[i][2]++;
A[i][3]++;
}
solve(A, K);
assert(false);
return 0;
}