#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[300001];
set<long long> my, his;
long long dfs(long long x, long long p) {
  long long i, ch, k;
  if (my.find(x) != my.end()) {
    return x;
  }
  for (i = 0; i < adj[x].size(); i++) {
    ch = adj[x][i];
    if (ch != p) {
      k = dfs(ch, x);
      if (k != 0) return k;
    }
  }
  return 0;
}
int main() {
  long long m, z, i, j, lt, x, y, d, r, q, k, g, t, n;
  vector<long long> a(300001), b(300001), c(300001), tx, ps;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n;
    for (i = 1; i <= n; i++) adj[i].clear();
    my.clear();
    his.clear();
    for (i = 1; i < n; i++) {
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    long long km, kh;
    cin >> km;
    for (i = 0; i < km; i++) {
      cin >> x;
      my.insert(x);
    }
    cin >> kh;
    for (i = 0; i < kh; i++) {
      cin >> x;
      his.insert(x);
    }
    cout << "B " << x << endl;
    cin >> x;
    if (my.find(x) != my.end()) {
      cout << "C " << x << endl;
      continue;
    }
    k = dfs(x, 0);
    if (k == 0)
      cout << -1 << endl;
    else {
      cout << "A " << k << endl;
      cin >> x;
      if (his.find(x) != his.end())
        cout << "C " << k << endl;
      else
        cout << "C -1" << endl;
    }
  }
}
