#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int n, x, k1, k2, a, b;
bool mark[N], vis[N];
vector<int> adj[N], vec;
void init() {
  memset(mark, 0, sizeof mark);
  memset(vis, 0, sizeof vis);
  vec.clear();
  for (int i = 0; i < N; i++) adj[i].clear();
}
void bfs(int src) {
  queue<int> q;
  q.push(src);
  int y;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    if (mark[u]) {
      y = u;
      break;
    }
    for (int v : adj[u])
      if (!vis[v]) q.push(v);
  }
  cout << "A " << y << endl;
  fflush(stdout);
  cin >> x;
  int ans = -1;
  for (int v : vec)
    if (v == x) {
      ans = y;
      break;
    }
  cout << "C " << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    init();
    cin >> n;
    for (int i = 1; i < n; i++)
      cin >> a >> b, adj[a].push_back(b), adj[b].push_back(a);
    cin >> k1;
    for (int i = 0; i < k1; i++) cin >> x, mark[x] = 1;
    cin >> k2;
    for (int i = 0; i < k2; i++) cin >> x, vec.push_back(x);
    cout << "B " << vec[0] << endl;
    fflush(stdout);
    cin >> x;
    bfs(x);
  }
}
