#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { int n; cin >> n; int a[n] = {}; int cnt = 0; int ite = 0; int x = -1; int y = -1; vector G[1000]; while(cnt < n-1){ if(a[ite] == 0){ if(x == -1){ x = ite + 1; }else{ cnt++; y = ite + 1; cout << "? " << x << ' ' << y << endl; fflush(stdout); int z; cin >> z; if(z == x){ a[y-1] = 1; G[x].push_back(y); }else{ a[x-1] = 1; G[y].push_back(x); } x = -1; y = -1; } }else{ ; } ite++; ite %= n; } int win = -1; rep(i,n){ if(a[i]==0){ win = i+1; } } int two = G[win][0]; srep(i,1,G[win].size()){ cout << "? " << two << ' ' << G[win][i] << endl; fflush(stdout); int z; cin >> z; two = z; } cout << "! " << two << endl; return 0; }