// @author godmar import java.util.*; public class TreasureGodmar { static Scanner sc = new Scanner(System.in); static boolean [][] ruledout = new boolean[4][4]; public static void main(String []av) { // Strategy: // Guess these coordinates until the first yes or // three guesses, whichever is earlier // 0b0b0 // a1a20 // 0b0b0 // a3a.0 // 00000 // Then guess the "a" and "b" relative to the first // correct guess. // int x, y = -1; free: for (x = 2; x <= 4; x += 2) { for (y = 2; y <= 4; y += 2) { if (x == 4 && y == 4 || guess(x, y)) break free; } } guess(x-1, y); guess(x, y-1); for (x = 0; x < 4; x++) { for (y = 0; y < 4; y++) { if (!ruledout[x][y]) { System.out.printf("! %d %d%n", x+1, y+1); System.out.flush(); return; } } } } static boolean guess(int x, int y) { System.out.printf("? %d %d%n", x, y); System.out.flush(); boolean present = sc.nextInt() == 1; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if ((x - i == 2 || x - i == 1) && (y - j == 2 || y - j == 1)) { // a 'no' rules out the four positions to the top and left if (!present) ruledout[i][j] = true; } else { // a 'yes' rules out all positions except the four to the top and left if (present) ruledout[i][j] = true; } } } return present; } }