← Home
package main

import (
	"fmt"
)

func main() {
	var t int
	if _, err := fmt.Scan(&t); err != nil {
		return
	}
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		adj := make([][]int, n+1)
		for j := 0; j < n-1; j++ {
			var u, v int
			fmt.Scan(&u, &v)
			adj[u] = append(adj[u], v)
			adj[v] = append(adj[v], u)
		}

		tin := make([]int, n+1)
		tout := make([]int, n+1)
		parent := make([]int, n+1)
		timer := 0

		var dfs func(u, p int)
		dfs = func(u, p int) {
			timer++
			tin[u] = timer
			parent[u] = p
			for _, v := range adj[u] {
				if v != p {
					dfs(v, u)
				}
			}
			timer++
			tout[u] = timer
		}
		dfs(1, 1)

		S := make([]int, 0, n)
		for j := 1; j <= n; j++ {
			S = append(S, j)
		}

		seen := make([]int, n+1)
		gen := 0

		for len(S) > 1 {
			bestX := -1
			minMax := n + 2

			for x := 1; x <= n; x++ {
				s1Size := 0
				s0Size := 0
				gen++
				for _, v := range S {
					if tin[x] <= tin[v] && tout[v] <= tout[x] {
						s1Size++
					} else {
						p := parent[v]
						if seen[p] != gen {
							seen[p] = gen
							s0Size++
						}
					}
				}
				curMax := s1Size
				if s0Size > curMax {
					curMax = s0Size
				}
				if curMax < minMax {
					minMax = curMax
					bestX = x
				}
			}

			fmt.Printf("? %d\n", bestX)
			var resp int
			fmt.Scan(&resp)

			newS := make([]int, 0, n)
			gen++
			for _, v := range S {
				if resp == 1 {
					if tin[bestX] <= tin[v] && tout[v] <= tout[bestX] {
						newS = append(newS, v)
					}
				} else {
					if !(tin[bestX] <= tin[v] && tout[v] <= tout[bestX]) {
						p := parent[v]
						if seen[p] != gen {
							seen[p] = gen
							newS = append(newS, p)
						}
					}
				}
			}
			S = newS
		}

		fmt.Printf("! %d\n", S[0])
	}
}