#include using namespace std; using ll = long long; #ifdef LOCAL #include #else #define debug(...) #endif // 離散関数 f: Z -> R の区間 [left, right] での黄金分割探索 template auto golden_section_search(ll left, ll right, F&& f, bool maximize = true) { ll a = left - 1, x, b; { ll s = 1, t = 2; while (t < right - left + 2) swap(s += t, t); x = a + t - s, b = a + t; } T fx = f(x); while (a + b != 2 * x) { ll y = a + b - x; T fy = f(y); if (right < y || maximize ? fx < fy : fx > fy) { a = x, x = y, fx = fy; } else { b = a, a = y; } } return make_pair(x, fx); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int H, W; cin >> H >> W; // H を特定 // int local_ans_h = 17, local_ans_w = 334; auto check = [&](int h, int w) -> int { cout << "? " << h << " " << w << endl; // int d = (local_ans_h - h) * (local_ans_h - h) + (local_ans_w - w) * (local_ans_w - w); int d; cin >> d; if (d == -1) exit(0); return d; }; auto f1 = [&](int h) -> int { return check(h, 1); }; auto [h, d1] = golden_section_search(1, H, f1, false); auto f2 = [&](int w) -> int { return check(h, w); }; auto [w, d2] = golden_section_search(1, W, f2, false); cout << "! " << h << " " << w << endl; }