#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int head[N], tot;
bool t1[N], t2[N], vis[N];
struct Edge {
  int to, next;
} e[N << 1];
void init() {
  memset(head, -1, sizeof(head));
  memset(t1, false, sizeof(t1));
  memset(t2, false, sizeof(t2));
  tot = 0;
}
void addedge(int u, int v) {
  e[tot].to = v;
  e[tot].next = head[u];
  head[u] = tot++;
}
int print(char c, int x) {
  cout << c << " " << x << endl;
  fflush(stdout);
  int p;
  cin >> p;
  return p;
}
int dfs(int u, int fa) {
  if (t1[u]) return u;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa) continue;
    int t = dfs(v, u);
    if (t != -1) return t;
  }
  return -1;
}
int bfs(int x) {
  memset(vis, false, sizeof(vis));
  queue<int> q;
  q.push(x);
  vis[x] = true;
  while (!q.empty()) {
    int u = q.front();
    if (t1[u]) return u;
    q.pop();
    for (int i = head[u]; ~i; i = e[i].next) {
      int v = e[i].to;
      if (vis[v]) continue;
      q.push(v);
      vis[v] = true;
    }
  }
  return -1;
}
void solve() {
  init();
  int n, k1, k2, x;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    addedge(u, v);
    addedge(v, u);
  }
  cin >> k1;
  for (int i = 1; i <= k1; i++) cin >> x, t1[x] = true;
  cin >> k2;
  for (int i = 1; i <= k2; i++) cin >> x, t2[x] = true;
  x = print('B', x);
  if (t1[x]) {
    cout << "C " << x << endl;
    fflush(stdout);
    return;
  } else {
    x = dfs(x, 0);
    if (x == -1) {
      cout << "C -1" << endl;
      fflush(stdout);
    } else {
      int y = print('A', x);
      if (t2[y]) {
        cout << "C " << x << endl;
        fflush(stdout);
      } else {
        cout << "C -1" << endl;
        fflush(stdout);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
