#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	const int D = 14;
	int N, T;
	cin >> N >> T;
	vector<int> X(N), Y(N);
	for (int i = 0; i < N; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		X[i] = (a - 1) * D + (b - 1);
		Y[i] = (c - 1) * D + (d - 1);
	}
	vector<vector<int> > v;
	for (int i = 1; i <= D; i++) {
		for (int j = 1; j <= D; j++) {
			if (j != D) {
				v.push_back({i, j, i, j + 1});
			}
			if (i != D) {
				v.push_back({i, j, i + 1, j});
			}
		}
	}
	auto level = [](int x) {
		return __builtin_ctz(x);
	};
	auto dist = [](const vector<int>& v) {
		return abs(v[0] - 8) + abs(v[1] - 8) + abs(v[2] - 8) + abs(v[3] - 8);
	};
	sort(v.begin(), v.end(), [&](vector<int> vx, vector<int> vy) {
		int lx = max({level(vx[0]), level(vx[1]), level(vx[2]), level(vx[3])});
		int ly = max({level(vy[0]), level(vy[1]), level(vy[2]), level(vy[3])});
		if (lx != ly) return lx > ly;
		return dist(vx) < dist(vy);
	});
	int cur = 0;
	for (int i = 0; i < T; i++) {
		int a, b;
		cin >> a >> b;
		if (i < T / 4) {
			cout << 2 << endl;
		}
		else if (i < T * 3 / 4) {
			int req = int(10000000 / sqrt(b));
			if (a >= req) {
				cout << 1 << ' ' << v[cur][0] << ' ' << v[cur][1] << ' ' << v[cur][2] << ' ' << v[cur][3] << endl;
				cur += 1;
			}
			else {
				cout << 3 << endl;
			}
		}
		else {
			cout << 3 << endl;
		}
	}
	return 0;
}