#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MAXN = 1005;
const long long INF = 1e18;
const long double PI = acos((long double)-1);
vector<long long> adjlist[MAXN];
long long ans;
bool subtree[MAXN], found;
void dfs(long long u, long long par) {
  if (subtree[u]) {
    ans = u;
    found = 1;
    return;
  }
  for (auto v : adjlist[u]) {
    if (v == par)
      continue;
    else
      dfs(v, u);
    if (found) return;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long tc;
  cin >> tc;
  while (tc--) {
    found = 0;
    long long n;
    cin >> n;
    for (long long i = (1); i <= (n); i++) adjlist[i].clear(), subtree[i] = 0;
    for (long long i = (1); i <= (n - 1); i++) {
      long long a, b;
      cin >> a >> b;
      adjlist[a].push_back(b);
      adjlist[b].push_back(a);
    }
    long long k1, k2, x;
    cin >> k1;
    for (long long i = (1); i <= (k1); i++) {
      cin >> x;
      subtree[x] = 1;
    }
    set<long long> st2;
    cin >> k2;
    for (long long i = (1); i <= (k2); i++) {
      cin >> x;
      st2.insert(x);
    }
    cout << "B " << x << '\n';
    cout.flush();
    long long ff;
    cin >> ff;
    dfs(ff, ff);
    cout << "A " << ans << '\n';
    cout.flush();
    cin >> ff;
    if (st2.count(ff))
      cout << "C " << ans << '\n';
    else
      cout << "C -1\n";
    cout.flush();
  }
}
