#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long power(long long x, long long p, long long MOD) {
  if (p == 0) return 1 % MOD;
  if (p == 1) return x % MOD;
  long long res = power(x, p / 2, MOD);
  res = (long long)res * res % MOD;
  if (p & 1) res = (long long)res * x % MOD;
  return res;
}
const long long N = 1005;
vector<long long> adj[N];
set<long long> s[2];
long long color[N];
void dfs(long long u, long long p) {
  if (s[0].count(u))
    color[u] = u;
  else
    color[u] = color[p];
  for (long long v : adj[u])
    if (v != p) dfs(v, u);
}
long long ask_mine(long long x) {
  cout << "A " << x << endl;
  long long res;
  cin >> res;
  return res;
}
long long ask_his(long long x) {
  cout << "B " << x << endl;
  long long res;
  cin >> res;
  return res;
}
void solve() {
  long long n;
  cin >> n;
  for (long long i = 0; i < 2; i++) s[i].clear();
  for (long long i = 1; i <= n; i++) adj[i].clear();
  for (long long i = 1; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (long long i = 0; i < 2; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      long long x;
      cin >> x;
      s[i].insert(x);
    }
  }
  dfs(*s[0].begin(), -1);
  long long u = ask_his(*s[1].begin());
  long long v = ask_mine(color[u]);
  if (s[1].count(v))
    cout << "C " << color[u] << endl;
  else
    cout << "C -1" << endl;
}
int32_t main() {
  long long t;
  cin >> t;
  while (t--) solve();
}
