#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int cases, n, k, k2, u, v, p[N], x[N], y[N];
bool fnd[N], fnd2[N];
vector<int> adj[N];
void dfs(int u, int p2) {
  p[u] = p2;
  for (int i = 0, v; i < adj[u].size(); i++) {
    v = adj[u][i];
    if (v == p2) continue;
    dfs(v, u);
  }
}
void solve() {
  cin >> cases;
  while (cases--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      fnd[i] = 0;
      fnd2[i] = 0;
      p[i] = -1;
      adj[i].clear();
    }
    for (int i = 1; i < n; i++) {
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    cin >> k;
    for (int i = 1; i <= k; i++) {
      cin >> x[i];
      fnd[x[i]] = 1;
    }
    cin >> k2;
    for (int i = 1; i <= k2; i++) {
      cin >> y[i];
      fnd2[y[i]] = 1;
    }
    if (k >= 1)
      dfs(x[1], -1);
    else
      dfs(1, -1);
    if (k2 >= 1) {
      cout << "B " << y[1] << "\n";
      cout.flush();
    } else {
      cout << "C -1\n";
      cout.flush();
      continue;
    }
    cin >> u;
    if (u == -1) return;
    while (1) {
      if (u == -1) {
        cout << "C -1\n";
        cout.flush();
        break;
      }
      if (fnd[u]) {
        cout << "A " << u << "\n";
        cout.flush();
        cin >> v;
        if (v == -1) return;
        if (fnd2[v])
          cout << "C " << u << "\n";
        else
          cout << "C -1\n";
        cout.flush();
        break;
      }
      u = p[u];
    }
  }
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
