#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9,
                inf = 1e18 + 7;
const long long infll = 1e18 + 7;
long long n, m1, m2;
vector<long long> adj[N];
bool ck[N], ck1[N], ck2[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long q;
  cin >> q;
  while (q--) {
    cin >> n;
    for (long long i = 1; i <= n; i++) {
      adj[i].clear();
      ck[i] = 0;
      ck1[i] = 0;
      ck2[i] = 0;
    }
    for (long long i = 1; i < n; i++) {
      long long u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    cin >> m1;
    for (long long i = 1; i <= m1; i++) {
      long long x;
      cin >> x;
      ck1[x] = 1;
    }
    cin >> m2;
    long long u;
    for (long long i = 1; i <= m2; i++) {
      cin >> u;
      ck2[u] = 1;
    }
    cout << "B " << u << endl;
    long long que;
    cin >> que;
    queue<long long> qu;
    qu.push(que);
    long long cac;
    while (!qu.empty()) {
      long long t = qu.front();
      qu.pop();
      if (ck1[t]) {
        cac = t;
        break;
      }
      ck[t] = 1;
      for (auto v : adj[t]) {
        if (!ck[v]) {
          qu.push(v);
          ck[v] = 1;
        }
      }
    }
    cout << "A " << cac << endl;
    que;
    cin >> que;
    if (ck2[que]) {
      cout << "C " << cac << endl;
    } else {
      cout << "C " << -1 << endl;
    }
  }
}
