func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e3 + 5;   const int inf = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const double eps = 1e-6;   vector<int> g[maxn];   vector<int> tree[maxn];   int deep[maxn], son[maxn];   int cnt, mx;   void dfs(int x, int y) {     int sz = g[x].size();     deep[x] = 0;     son[x] = -1;     for (int i = 0; i < sz; ++i) {       int to = g[x][i];       if (to == y) {         continue;       }       tree[x].push_back(to);       dfs(to, x);       if (son[x] == -1 || deep[son[x]] < deep[to]) {         son[x] = son[to];       }     }     if (son[x] == -1) {       son[x] = x;     } else {       deep[x] = deep[son[x]] + 1;     }   }   struct node {     int id, w;     bool operator<(const node& rhs) const { return w > rhs.w; }   } nd[maxn];   int solve(int x) {     int sz = tree[x].size();     for (int i = 0; i < sz; ++i) {       nd[i] = {tree[x][i], deep[tree[x][i]]};     }     sort(nd, nd + sz);     int hf = sz / 2;     for (int i = 0; i < hf; ++i) {       int a = nd[i * 2].id, b = nd[i * 2 + 1].id;       ++cnt;       printf( ? %d %d n , son[a], son[b]);       fflush(stdout);       int c;       scanf( %d , &c);       if (c != x) {         return solve(c);       }       if (cnt >= mx) break;     }     if ((sz & 1) == 1 && cnt < mx) {       ++cnt;       printf( ? %d %d n , x, son[nd[sz - 1].id]);       fflush(stdout);       int c;       scanf( %d , &c);       if (c != x) {         return solve(c);       }     }     return x;   }   int main() {     int n;     scanf( %d , &n);     cnt = 0, mx = n / 2;     for (int i = 1; i < n; ++i) {       int u, v;       scanf( %d%d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);     }     dfs(1, -1);     printf( ! %d n , solve(1));     fflush(stdout);     return 0;   }   