#include <bits/stdc++.h>
using namespace std;
bool mark[1005];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<int>> adj(n + 1);
    for (int i = 1, u, v; i < n; ++i) {
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    memset(mark, 0, sizeof mark);
    int k1, k2;
    cin >> k1;
    vector<int> my(k1);
    for (auto &i : my) cin >> i, mark[i] = true;
    cin >> k2;
    vector<int> ot(k2);
    for (auto &i : ot) cin >> i;
    cout << "B " << ot[0] << "\n";
    fflush(stdout);
    int to;
    cin >> to;
    int from = my[0];
    function<int(int, int)> dfs = [&](int u, int p) {
      if (u == to) return mark[u] ? u : (1 << 30);
      int ans = -1;
      for (auto v : adj[u])
        if (v != p) ans = max(ans, dfs(v, u));
      if (ans == 1 << 30 && mark[u]) ans = u;
      return ans;
    };
    int x = dfs(from, -1), a;
    cout << "A " << x << "\n";
    fflush(stdout);
    cin >> a;
    bool ok = false;
    for (auto i : ot) ok |= i == a;
    if (ok)
      cout << "C " << x << "\n";
    else
      cout << "C -1\n";
    fflush(stdout);
  }
  return 0;
}
