#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
vector<int> G[N];
int va[N], vb[N];
int ask(char op, int x) {
  cout << op << " " << x << endl;
  cin >> x;
  return x;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    memset(va, 0, sizeof va);
    memset(vb, 0, sizeof vb);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) G[i].clear();
    for (int i = 1, a, b; i < n; i++) {
      cin >> a >> b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    int k1, k2;
    cin >> k1;
    while (k1--) {
      int x;
      cin >> x;
      va[x] = 1;
    }
    cin >> k2;
    int y;
    while (k2--) {
      int x;
      cin >> x;
      vb[x] = 1;
      y = x;
    }
    int res = ask('B', y);
    if (va[res]) {
      cout << "C " << res << endl;
      continue;
    }
    int ans = 0;
    function<void(int, int)> foo;
    foo = [&](int fa, int u) {
      for (int v : G[u]) {
        if (v == fa) continue;
        if (va[v]) {
          ans = v;
          continue;
        }
        foo(u, v);
      }
    };
    foo(-1, res);
    res = ask('A', ans);
    if (vb[res]) {
      cout << "C " << ans << endl;
    } else {
      cout << "C " << -1 << endl;
    }
  }
  return 0;
}
