#include <bits/stdc++.h>
using namespace std;
const long long N = 200000;
long long t, n, k1, k2, dis[N], ans, anns;
vector<long long> g[N];
set<long long> a, b;
void dfs(long long v, long long par) {
  if (a.find(v) != a.end() and dis[v] <= anns) {
    anns = dis[v];
    ans = v;
  }
  for (long long i = 0; i < g[v].size(); i++) {
    long long u = g[v][i];
    if (u == par) continue;
    dis[u] = dis[v] + 1;
    dfs(u, v);
  }
}
int main() {
  cin >> t;
  while (t--) {
    for (long long i = 0; i < 1331; i++) {
      g[i].clear();
      dis[i] = 0;
    }
    cin >> n;
    for (long long i = 1; i < n; i++) {
      long long u, v;
      cin >> v >> u;
      g[v].push_back(u), g[u].push_back(v);
    }
    a.clear();
    b.clear();
    long long now = 0;
    cin >> k1;
    for (long long i = 1; i <= k1; i++) {
      long long p;
      cin >> p;
      a.insert(p);
    }
    cin >> k2;
    for (long long i = 1; i <= k2; i++) {
      long long p;
      cin >> p;
      b.insert(p);
      now = p;
    }
    cout << "B " << now << endl;
    cin >> now;
    if (a.find(now) != a.end()) {
      cout << "C " << now << endl;
      continue;
    }
    anns = 1e18;
    dfs(now, 0);
    cout << "A " << ans << endl;
    cin >> now;
    if (b.find(now) != b.end()) {
      cout << "C " << ans << endl;
      continue;
    }
    cout << "C -1\n";
  }
}
