| 237 | } |
| 238 | |
| 239 | public static void main(String[] args) throws Exception { |
| 240 | FastReader in = new FastReader(System.in); |
| 241 | PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); |
| 242 | n = in.nextInt(); |
| 243 | for (int i = 1, u, v; i < n; i++) { |
| 244 | u = in.nextInt(); |
| 245 | v = in.nextInt(); |
| 246 | addEdgeG(u, v); |
| 247 | addEdgeG(v, u); |
| 248 | } |
| 249 | dfs(1, 0); |
| 250 | q = in.nextInt(); |
| 251 | for (int t = 1; t <= q; t++) { |
| 252 | k = in.nextInt(); |
| 253 | for (int i = 1; i <= k; i++) { |
| 254 | order[i] = in.nextInt(); |
| 255 | } |
| 256 | compute(); |
| 257 | for (int i = 1; i <= k; i++) { |
| 258 | out.print(ans[order[i]] + " "); |
| 259 | } |
| 260 | out.println(); |
| 261 | } |
| 262 | out.flush(); |
| 263 | out.close(); |
| 264 | } |
| 265 | |
| 266 | // 读写工具类 |
| 267 | static class FastReader { |