#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e3;   int N, p[MAXN + 1];   set<int> adj[MAXN + 1];   void dfs(int v, int padre) {     p[v] = padre;     for (auto x : adj[v]) {       if (x == padre || p[x]) continue;       p[x] = padre;       dfs(x, v);     }     adj[v].clear();   }   int main() {     ios_base::sync_with_stdio(false);     cin >> N;     for (int i = 0; i < N - 1; i++) {       int u, v;       cin >> u >> v;       adj[u].insert(v);       adj[v].insert(u);     }     while (1) {       int cnt = 0;       int Max = 0, pos = 0;       for (int i = 1; i <= N; i++) {         if (!p[i]) {           cnt++;           int sz = adj[i].size();           if (sz > Max) {             Max = sz;             pos = i;           }         }       }       if (cnt == 1) {         for (int i = 1; i <= N; i++) {           if (!p[i]) {             cout <<  !   << i << endl;             break;           }         }         break;       } else if (cnt == 2) {         int u = -1, v = -1;         for (int i = 1; i <= N; i++) {           if (!p[i]) {             if (u == -1)               u = i;             else               v = i;           }         }         cout <<  ?   << u <<     << v << endl;         int lca;         cin >> lca;         cout <<  !   << lca << endl;         break;       }       int u = -1, v = -1;       vector<int> del;       for (auto x : adj[pos]) {         if (u == -1)           u = x;         else           v = x;         if (u != -1 && v != -1) {           cout <<  ?   << u <<     << v << endl;           int lca;           cin >> lca;           if (lca == u || lca == v) {             dfs(pos, lca);             u = v = -1;             del.clear();             break;           } else {             dfs(u, pos);             dfs(v, pos);             del.push_back(u);             del.push_back(v);             u = v = -1;           }         }       }       for (auto x : del) adj[pos].erase(x);     }   }   