#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e3 + 10;
const int inf = (int)2e9;
vector<int> adj[N];
int my[N], other[N];
int dfs(int u, int p) {
  if (my[u] == 1) return u;
  int ret = -1;
  for (int v : adj[u]) {
    if (v != p) {
      ret = dfs(v, u);
      if (ret != -1) return ret;
    }
  }
  return ret;
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    for (int i = 0; i < N; i++) {
      adj[i].clear(), my[i] = 0, other[i] = 0;
    }
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++) {
      int u, v;
      scanf("%d %d", &u, &v);
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    int k1;
    scanf("%d", &k1);
    for (int i = 0; i < k1; i++) {
      int u;
      scanf("%d", &u);
      my[u] = 1;
    }
    int k2, node;
    scanf("%d", &k1);
    for (int i = 0; i < k2; i++) {
      int u;
      scanf("%d", &u);
      other[u] = 1;
      node = u;
    }
    printf("B %d\n", node);
    fflush(stdout);
    int x;
    scanf("%d", &x);
    if (my[x] == 1) {
      printf("C %d\n", x);
      fflush(stdout);
      continue;
    } else {
      int closest = dfs(x, x);
      printf("A %d\n", closest);
      fflush(stdout);
      int answer = -1;
      scanf("%d", &x);
      if (other[x] == 1) answer = closest;
      printf("C %d\n", answer);
      fflush(stdout);
    }
  }
  return 0;
}
