def main(): _n, _t = map(int, input().split()) dp = [[0 for j in range(14 * 14)] for i in range(14 * 14)] for start_i in range(0, 14): for start_j in range(0, 14): for goal_i in range(0, 14): for goal_j in range(0, 14): value = abs(start_i - start_j) + abs(goal_i - goal_j) dp[start_i * 14 + start_j][goal_i * 14 + goal_j] = value * 1000 dp[goal_i * 14 + goal_j][start_i * 14 + start_j] = value * 1000 sum_s = 0 paths = {} for _ in range(3000): a, b, c, d = map(int, input().split()) a -= 1 b -= 1 c -= 1 d -= 1 paths[(a, b, c, d)] = dp[a * 14 + b][c * 14 + d] paths[(a, b, c, d)] = dp[c * 14 + d][a * 14 + b] highway_count = 0 collaborator_count = 0 money = 10**6 edges = [] for i in range(14): for j in range(14): for (di, dj) in [(1, 0), (0, 1), (-1, 0), (0, -1)]: idi = i + di jdj = j + dj if 0 <= idi < 14 and 0 <= jdj < 14: if (i, j, idi, jdj) not in edges: edges.append((i, j, idi, jdj)) best_edges = [] for edge in edges: edge_value = 0 for start_i in range(0, 14): for start_j in range(0, 14): for goal_i in range(0, 14): for goal_j in range(0, 14): (x, y, z, w) = edge new_length = min( paths[start_i * 14 + start_j][x * 14 + y] + paths[z * 14 + w][goal_i * 14 + goal_j], paths[start_i * 14 + start_j][z * 14 + w] + paths[x * 14 + y][goal_i * 14 + goal_j], ) if dp[start_i * 14 + start_j][goal_i * 14 + goal_j] > new_length: edge_value += 1 best_edges.append((edge_value, edge)) best_edges.sort(reverse=True) for t in range(400): u, v = map(int, input().split()) money = u collaborator_count = v idx = 0 if collaborator_count < 25: print(2, flush=True) elif money < 10**7 // 5 or highway_count >= 20: print(3, flush=True) else: x, y, z, w = best_edges[idx] idx += 1 print(1, x + 1, y + 1, z + 1, w + 1, flush=True) if "__main__" == __name__: main()