#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N = 2e5+5;
int n, cnt, vis[N], siz[N], sy;
int xw[N][3], now;
int dp[N][3], path[N][3];
vector<int> g[N];
void dfs(int u, int fa) {
dp[u][0] = dp[u][1] = dp[u][2] = 0;
path[u][0] = path[u][1] = path[u][2] = 0;
xw[u][0] = xw[u][1] = xw[u][2] = 0;
siz[u] = 1;
int t = 0;
for(auto x : g[u]) {
if(x == fa) continue;
if(!vis[x]) continue;
dfs(x,u);
siz[u] += siz[x];
dp[u][t] = siz[x];
path[u][t] = x;
t ++;
}
if(fa) {
dp[u][t] = cnt - siz[u];
path[u][t] = fa;
}
int pos = -1, minn = 1e9, res = 0;
for(int i=0;i<3;i++) {
if(minn > dp[u][i]) minn = dp[u][i], pos = i;
}
if(pos == -1) TLE();
dp[u][pos] ++;
t = 0;
for(int i=0;i<3;i++) {
res = max(res, dp[u][i]);
if(i == pos) {
xw[u][2] = path[u][i];
continue;
}
xw[u][t] = path[u][i];
t ++;
}
if(res < sy) {
now = u;
sy = res;
}
}
void dfs2(int u, int fa) {
vis[u] = 0;
cnt --;
for(int x : g[u]) {
if(x == fa) continue;
if(vis[x] == 0) break;
dfs2(x,u);
}
}
void TLE() {
ll c = 100000000000ll;
int res = 0;
while(c --) {
res = res + 1 + res;
res %= 12341231;
}
cout << res << '\n';
}
void solve() {
cin >> n;
for(int i=1;i<=n;i++) {
g[i].clear();
}
for(int i=1;i<=n;i++) {
vis[i] = 1;
int x, y;
cin >> x >> y;
if(x) g[x].push_back(i), g[i].push_back(x);
if(y) g[y].push_back(i), g[i].push_back(y);
}
cnt = n;
int st = 1;
while(cnt > 1) {
if(cnt == 2) {
int x = 0, y = 0, t;
for(int i=1;i<=n;i++) {
if(vis[i]) {
if(x) y = i;
else x = i;
}
}
if(x == 0 || y == 0) TLE();
cout << "? " << x << ' ' << y << endl;
cin >> t;
if(t == 0) cout << "! " << x << endl;
else cout << "! " << y << endl;
return ;
}
if(st == 0 || st > n) TLE();
sy = cnt;
// cerr << "#" << ' ' << st << ' ' << sy << '\n';
dfs(st,0);
int t;
cout << "? " << xw[now][0] << ' ' << xw[now][1] << endl;
cin >> t;
int fx;
if(t == 0) {
vis[now] = 0;
cnt --;
fx = xw[now][0];
st = fx;
for(auto x : g[now]) {
if(x == fx) continue;
if(vis[x] == 0) continue;
dfs2(x,now);
}
} else if(t == 2) {
vis[now] = 0;
cnt --;
fx = xw[now][1];
st = fx;
// cerr << "* " << now << ' ' << fx << '\n';
for(auto x : g[now]) {
if(x == fx) continue;
if(vis[x] == 0) continue;
dfs2(x,now);
}
} else {
st = now;
fx = xw[now][2];
// cerr << "* " << now << ' ' << fx << '\n';
for(auto x : g[now]) {
if(x == fx) continue;
if(vis[x] == 0) continue;
dfs2(x,now);
}
}
}
for(int i=1;i<=n;i++) {
if(vis[i]) {
cout << "! " << i << endl;
return ;
}
}
// TLE();
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while(t --) solve();
return 0;
}