#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int t, n, k1, k2, ans;
vector<int> adj[N];
set<int> my, his;
int dfs(int v, int par = -1) {
  if (my.find(v) != my.end()) return v;
  for (auto u : adj[v]) {
    if (u != par) {
      int cur = dfs(u, v);
      if (cur != -1) return cur;
    }
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i < n; i++) {
      int u, v;
      cin >> u >> v;
      u--, v--;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    cin >> k1;
    for (int i = 0; i < k1; i++) {
      int a;
      cin >> a;
      my.insert(a - 1);
    }
    cin >> k2;
    for (int i = 0; i < k2; i++) {
      int a;
      cin >> a;
      his.insert(a - 1);
    }
    int t1;
    cout << "B " << *his.begin() + 1 << endl;
    cin >> t1;
    if (my.find(t1 - 1) != my.end())
      ans = t1;
    else {
      int u = dfs(t1 - 1);
      assert(u != -1);
      cout << "A " << u + 1 << endl;
      int w;
      cin >> w;
      w--;
      if (his.find(w) != his.end())
        ans = u + 1;
      else
        ans = -1;
    }
    cout << "C " << ans << endl;
    for (int i = 0; i < n; i++) adj[i].clear();
    my.clear();
    his.clear();
  }
}
