#!/usr/bin/env python3 # Query a + and then start DFS at the best pos. import random n = int(input()) d = [(-1, 0), (0, 1), (1, 0), (0, -1)] def q(x, y): if x < 1 or x > n or y < 1 or y > n: return -1 print("?", x, y) return int(input()) x, y = 1, 1 # Sample n random points, and start at the best one. best = 0 for xi in range(1, n + 1): yi = n // 2 v = q(xi, yi) if v > best: best = v x, y = xi, yi for yi in range(1, n + 1): xi = n // 2 v = q(xi, yi) if v > best: best = v x, y = xi, yi while True: v = q(x, y) # Choose the best neighbour best = (v, None) for dx, dy in d: best = max(best, (q(x + dx, y + dy), (x + dx, y + dy))) if best[1] is not None: x, y = best[1] else: print("!", v) break