#include using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repn(i, m, n) for (int i = m; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define debug(x) cerr << #x << ": " << x << endl; using Graph = vector>; // グラフ型 template bool chmin(T &a, T b) { if (a > b) { a = b; return true; } else return false; } // 定数 #define INF32 2147483647 // 2.147483647×10^{9}:32bit整数のinf #define INF64 9223372036854775807 // 9.223372036854775807×10^{18}:64bit整数のinf const ll INF = 1LL << 60; // const int MOD = 1e9 + 7; const int MOD = 1000000007; // 大きい順にソートさせる比較関数を直接渡す // sort(v.begin(), v.end(), [](int a, int b) { return a > b; }); // modint: mod 計算を int を扱うように扱える構造体 template struct Fp { long long val; constexpr Fp(long long v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr int getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { long long a = r.val, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp &x) noexcept { return os << x.val; } friend constexpr Fp modpow(const Fp &a, long long n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; using mint = Fp; struct UnionFind { vector par, siz; UnionFind(int n) : par(n, -1), siz(n, 1) {} // search root int root(int x) { if (par[x] == -1) return x; else return par[x] = root(par[x]); } // same group? bool issame(int x, int y) { return root(x) == root(y); } // unite bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); par[y] = x; siz[x] += siz[y]; return true; } int size(int x) { return siz[root(x)]; } }; void dfs(const Graph &G, int v, vector &seen) { seen[v] = true; for (auto next_v : G[v]) { if (seen[next_v]) continue; dfs(G, next_v, seen); } return; } // int main() { int N, T; cin >> N >> T; const int MAXX = 15, MAXY = 15; vector A(N), B(N), C(N), D(N); rep(i, N) cin >> A[i] >> B[i] >> C[i] >> D[i]; // とりあえず貪欲に解く // N人の人の経路に一番重複しそうな区間を選んで工事 // 工事できるまで協力者を集め、集まったら即工事する vector> x_road_weight(MAXY + 1, vector(MAXX + 1, 0)); // (y,x)から東に出る道の重み vector> y_road_weight(MAXY + 1, vector(MAXX + 1, 0)); // (y,x)から南に出る道の重み // 一次元配列にしてソートする // 各インデックスごとに区間ペアを作っておく vector road_weight(2 * MAXX * MAXY + 10, 0); vector> road_idx(2 * MAXX * MAXY + 10); vector> next_idx(2 * MAXX * MAXY + 10); const int NS = MAXX * MAXY; // North to South const int WE = 0; // West to East for (int i = 0; i < MAXY; i++) { for (int j = 0; j < MAXX; j++) { road_idx[WE + i * MAXX + j] = {i, j}; road_idx[NS + i * MAXX + j] = {i, j}; next_idx[WE + i * MAXX + j] = {0, 1}; next_idx[NS + i * MAXX + j] = {1, 0}; } } // マンハッタン距離で評価 for (int p = 0; p < N; p++) { int nwx = min(B[p], D[p]); // north west int nwy = min(A[p], C[p]); // north west int sex = max(B[p], D[p]); // south east int sey = max(A[p], C[p]); // south east for (int i = nwy; i < sey; i++) { for (int j = nwx; j < sex; j++) { road_weight[NS + i * MAXY + j] += 1; road_weight[WE + i * MAXY + j] += 1; x_road_weight[i][j] += 1; y_road_weight[i][j] += 1; } } } vector> sorted_road_weight(2 * MAXX * MAXY + 10); for (int n = 0; n < 2 * MAXX * MAXY; n++) { sorted_road_weight[n] = {road_weight[n], n}; } sort(all(sorted_road_weight)); reverse(all(sorted_road_weight)); // 降順にする int construct_count = 0; ll current_money = 0, current_corps = 0; // cout << 2 << endl; // 最初はとりあえず集める for (int step = 0; step < T; step++) { cin >> current_money >> current_corps; ll construct_cost = round(10000000.0 / (double)sqrt(current_corps)); if (current_money == -1 && current_corps == -1) return 0; if (current_money >= construct_cost) { // 建設する int idx = sorted_road_weight[construct_count].second; construct_count++; cout << "1 " << road_idx[idx].first << " " << road_idx[idx].second << " " << road_idx[idx].first + next_idx[idx].first << " " << road_idx[idx].second + next_idx[idx].second << endl; } else { // 足りなければ協力者を集める cout << "2" << endl; } } return 0; }