func_code_string: #include <bits/stdc++.h>   using namespace std;   long long p[500002], d[200004], c, n, fix[200004];   vector<pair<long long, long long> > g;   vector<long long> v[200005];   void go(long long x, long long par, long long dep) {     p[x] = par;     d[x] = dep;     for (int i = 0; i < v[x].size(); i++)       if (v[x][i] != par) go(v[x][i], x, dep + 1);   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 1; i < n; i++) {       long long x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     go(1, 0, 0);     for (int i = 1; i <= n; i++) v[i].clear();     for (int i = 2; i <= n; i++) v[p[i]].push_back(i);     for (int i = 1; i <= n; i++) {       g.push_back(make_pair(d[i], i));     }     sort(g.begin(), g.end());     reverse(g.begin(), g.end());     for (int id = 0; id < g.size(); id++) {       long long x = g[id].second, par = p[x];       if (fix[x]) continue;       if (x == 1) {         cout <<  !   << x << endl;         return 0;       }       if (v[par].size() > 1) {         long long y = 0;         if (v[par][0] == x)           y = v[par][1];         else           y = v[par][0];         fix[x] = 1;         fix[y] = 1;         cout <<  ?   << x <<     << y << endl;         cin >> c;         if (c == x) {           cout <<  !   << x << endl;           return 0;         }         if (c == y) {           cout <<  !   << y << endl;           return 0;         }         for (int i = 0; i < v[par].size(); i++) {           if (v[par][i] == x || v[par][i] == y) {             swap(v[par][i], v[par][(int)v[par].size() - 1]);             v[par].pop_back();             i--;             continue;           }         }       } else {         if (par == 1) {           cout <<  ?   << x <<     << 1 << endl;           cin >> c;           cout <<  !   << c << endl;           return 0;         }         long long y = p[par];         cout <<  ?   << x <<     << y << endl;         cin >> c;         if (c == par) {           cout <<  !   << c << endl;           return 0;         }         if (c == x) {           cout <<  !   << c << endl;           return 0;         }         fix[x] = 1;         fix[par] = 1;         for (int i = 0; i < v[y].size(); i++)           if (v[y][i] == par) {             swap(v[y][i], v[y][(int)v[y].size() - 1]);             v[y].pop_back();             break;           }       }     }     return 0;   }   