#include <bits/stdc++.h>
using namespace std;
int ask(string q, int x) {
  cout << q << " " << x << endl;
  int ret;
  cin >> ret;
  return ret;
}
int getclosestnode(vector<vector<int>> &adj, set<int> &me, int node) {
  bool visited[1001];
  memset(visited, 0, sizeof visited);
  queue<int> q;
  q.push(node);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (me.count(u) != 0)
      return u;
    else
      for (auto x : adj[u])
        if (!visited[x]) {
          q.push(x);
          visited[x] = 1;
        }
  }
  return -1;
}
void solve() {
  int n;
  vector<vector<int>> adj(1001);
  cin >> n;
  for (int i = 0; i < (int)(n - 1); i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  set<int> me, li;
  int k;
  cin >> k;
  for (int i = 0; i < (int)(k); i++) {
    int a;
    cin >> a;
    me.insert(a);
  }
  cin >> k;
  for (int i = 0; i < (int)(k); i++) {
    int a;
    cin >> a;
    li.insert(a);
  }
  int node = ask("B", *li.begin());
  if (me.count(node) != 0)
    cout << "C " << node << endl;
  else {
    int closest = getclosestnode(adj, me, node);
    int liclose = ask("A", closest);
    if (li.count(liclose) != 0) {
      cout << "C " << closest << endl;
    } else
      cout << "C " << -1 << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc;
  cin >> tc;
  for (int i = 0; i < (int)(tc); i++) solve();
  return 0;
}
