#include #define ADD(a, b) a = (a + ll(b)) % mod #define MUL(a, b) a = (a * ll(b)) % mod #define MAX(a, b) a = max(a, b) #define MIN(a, b) a = min(a, b) #define rep(i, a, b) for(int i = int(a); i < int(b); i++) #define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--) #define all(a) (a).begin(), (a).end() #define sz(v) (int)(v).size() #define pb push_back #define sec second #define fst first #define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair pi; typedef pair pl; typedef pair ppi; typedef vector vi; typedef vector vl; typedef vector mat; typedef complex comp; void Debug() {cout << '\n'; } templatevoid Debug(FIRST arg, REST... rest){ cout<ostream& operator<<(ostream& out,const vector& v) { out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<ostream& operator<<(ostream& out,const pair& v){ out<<"("< vec; vector G[MAX_N]; void solve() { cin >> N; rep(i, 0, N) vec.pb(i); int cnt = 334; while(sz(vec) >= 2) { vector nvec; int n = sz(vec); for(int i = 0; i < n; i += 2) { if(i == n - 1) nvec.pb(vec[i]); else { int a = vec[i], b = vec[i + 1]; cout << "? " << a + 1 << " " << b + 1 << endl; cnt--; int c; cin >> c; c--; if(b == c) swap(a, b); nvec.pb(a); G[a].pb(b); } } vec = nvec; // debug(vec); } int root = vec[0]; int ans = -1; // debug(root, G[root]); rep(i, 0, sz(G[root])) { int b = G[root][i]; if(ans == -1) ans = b; else { cout << "? " << ans + 1 << " " << b + 1 << endl; cnt--; int c; cin >> c; c--; if(b == c) ans = b; } } while(cnt--) { cout << "? " << 1 << " " << 2 << endl; } cout << "! " << ans + 1 << endl; } int main() { solve(); }