import kotlin.random.Random fun main() { val n = readInt() val values = mutableMapOf, Long>() fun query(x: Int, y: Int) = values.getOrPut(x to y) { if (x !in 0 until n || y !in 0 until n) return@getOrPut -1L println("? ${x+1} ${y+1}") System.out.flush() readLong() } var cur = List(5 * n) { val x = Random.nextInt(n) val y = Random.nextInt(n) Random.nextInt(n) to Random.nextInt(n) }.maxBy { query(it.first, it.second) } val dirs = listOf(1 to 0, -1 to 0, 0 to 1, 0 to -1, 0 to 0) while (true) { val next = dirs.map { cur.first + it.first to cur.second + it.second }.maxBy { query(it.first, it.second) } if (next == cur) break cur = next } println("! ${query(cur.first, cur.second)}") } private fun readInt() = readln().toInt() private fun readLong() = readln().toLong()