#include <bits/stdc++.h>
#define ll long long
#define db double
#define fi first
#define se second
#define pb push_back
using namespace std;
ll read() {
ll x = 0, f = 1; char ch = getchar();
while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
return x * f;
}
ll gcd(ll x, ll y) {return y ? gcd(y, x % y) : x;}
ll rt, ct, fg[200010], zx, fa[200010];
ll n, sn[2][200010], siz[200010], num;
void dfs(int u) {
siz[u] = 1; int flag = 0;
for(int i = 0; i < 2; i++) {
if(!sn[i][u] || fg[sn[i][u]]) continue;
dfs(sn[i][u]); siz[u] += siz[sn[i][u]];
if(siz[sn[i][u]] > ct / 2) flag = 1;
}
if(ct - siz[u] > ct / 2) flag = 1;
if(!flag) zx = u;
}
void solve() {
n = read(); ct = n; rt = 1; num = 0;
for(int i = 1; i <= n; i++) fa[i] = siz[i] = fg[i] = 0;
for(int i = 1; i <= n; i++) {
sn[0][i] = read(), sn[1][i] = read();
fa[sn[0][i]] = fa[sn[1][i]] = i;
}
for(int i = 1; i <= n; i++) if(!fa[i]) rt = i;
while(ct > 1) {
if(T != 2) printf("%d\n", n), fflush(stdout);
dfs(rt); int u = fa[zx], v = fa[zx], ck;
if(!fa[zx] || fg[fa[zx]]) u = v = zx;
if(sn[0][zx] && !fg[sn[0][zx]]) u = sn[0][zx];
if(sn[1][zx] && !fg[sn[1][zx]]) v = sn[1][zx];
printf("? %d %d\n", u, v); fflush(stdout); ck = read();
if(ck == 1) {
if(u == fa[zx] || v == fa[zx]) {printf("! %lld\n", zx); break;}
fg[u] = fg[v] = 1; ct -= siz[u] + siz[v]; continue;
}
if(ck == 2) swap(u, v);
if(ct == 2) {printf("! %d\n", u); break;}
if(u == fa[zx]) {fg[zx] = 1; siz[u] -= siz[zx]; continue;}
rt = u; ct = siz[u]; fg[fa[u]] = 1;
}
if(ct == 1) printf("! %lld\n", rt);
fflush(stdout);
}
int main() {
int T = read();
for(int i = 1; i <= T; i++) solve();
return 0;
}
/*
2
5
0 0
1 5
2 4
0 0
0 0
*/