#include #include #include #include #include using namespace std; typedef long long ll; typedef long double ld; typedef pair ii; typedef vector vi; typedef vector vvi; typedef vector vii; #define x first #define y second #define pb push_back #define eb emplace_back #define rep(i,a,b) for(auto i=(a); i<(b); ++i) #define REP(i,n) rep(i,0,n) #define all(v) (v).begin(), (v).end() #define rs resize #define DBG(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl const ld PI = acos(-1.0); template using min_queue = priority_queue, greater>; template int sz(const T &x) { return (int) x.size(); // copy the ampersand(&)! } template ostream& operator<<(ostream &os, vector &v) { os << "\n["; for(T &x : v) os << x << ','; return os << "]\n"; } struct pairhash { public: template size_t operator()(const pair &p) const { size_t lhs = hash()(p.x); size_t rhs = hash()(p.y); return lhs ^ (rhs+0x9e3779b9+(lhs<<6)+(lhs>>2)); } }; ll n = -1; ll v = -1; ll bx = -1, by = -1; void read(ll x, ll y) { if (x <= 0 || y <= 0 || x > n || y > n) return; ll w; cout << "? " << x << " " << y << endl; cin >> w; if (w > v) { bx = x; by = y; v = w; } } void run() { cin >> n; if (n == 1) read(1, 1); ll lh = 1, uh = n, lw = 1, uw = n; while (lh != uh || lw != uw) { ll mw = (lw+uw)/2; ll mh = (lh+uh)/2; for (ll x = lw; x <= uw; x++) { read(x, mh); } for (ll y = lh; y <= uh; y++) { read(mw, y); } ll a = bx, b = by; for (ll x = a-1; x <= a+1; x++) { for (ll y = b-1; y <= b+1; y++) { read(x, y); } } if (bx == mw || by == mh) break; if (bx > mw) lw = mw+1; else uw = mw-1; if (by > mh) lh = mh+1; else uh = mh-1; } cout << "! " << v << endl; } signed main() { // DON'T MIX "scanf" and "cin"! ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(20); run(); return 0; }