#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e6 + 5, mod = 1e9 + 7;
vector<int> adj[mxN];
int n, x[mxN], y[mxN];
bool used[mxN], ok[mxN], o[mxN];
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= n; ++i) used[i] = ok[i] = o[i] = 0, adj[i].clear();
    for (int i = 1, u, v; i < n; ++i) {
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    int k1;
    cin >> k1;
    for (int i = 1; i <= k1; ++i) cin >> x[i], ok[x[i]] = 1;
    int k2;
    cin >> k2;
    for (int i = 1; i <= k2; ++i) cin >> y[i], o[y[i]] = 1;
    cout << "B " << y[1] << '\n';
    cout.flush();
    int node;
    cin >> node;
    queue<int> q;
    q.push(node);
    while (!q.empty()) {
      int v = q.front();
      if (ok[v]) {
        cout << "A " << v << '\n';
        cout.flush();
        int u;
        cin >> u;
        if (o[u])
          cout << "C " << v << '\n';
        else
          cout << "C -1\n";
        cout.flush();
        break;
      }
      q.pop();
      for (auto to : adj[v]) {
        if (!used[to]) {
          used[to] = 1;
          q.push(to);
        }
      }
    }
  }
  return 0;
}
