#include <bits/stdc++.h>
using namespace std;
const long long INFll = 1ll * 1000000100 * 1000000100;
const long double PI =
    3.141592653589793238462643383279502884197169399375105820974944;
vector<vector<int>> g;
int n;
vector<int> dist;
void bfs(int start) {
  dist.assign(n, 1000000100);
  queue<int> q;
  q.push(start);
  dist[start] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : g[u]) {
      if (dist[v] == 1000000100) {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }
}
void solve() {
  cin >> n;
  g.clear();
  g.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int k1, k2;
  set<int> me, you;
  cin >> k1;
  for (int i = 0; i < k1; i++) {
    int x;
    cin >> x;
    x--;
    me.insert(x);
  }
  cin >> k2;
  for (int i = 0; i < k2; i++) {
    int x;
    cin >> x;
    x--;
    you.insert(x);
  }
  int start;
  cout << "B " << (*you.begin()) + 1 << endl;
  fflush(stdout);
  cin >> start;
  start--;
  bfs(start);
  int mn = 1000000100, ver = -1;
  for (auto it = me.begin(); it != me.end(); it++) {
    if (dist[*it] < mn) {
      ver = *it;
      mn = dist[ver];
    }
  }
  cout << "A " << ver + 1 << endl;
  fflush(stdout);
  int ans;
  cin >> ans;
  ans--;
  if (you.count(ans)) {
    cout << "C " << ver + 1 << endl;
    fflush(stdout);
  } else {
    cout << "C " << -1 << endl;
    fflush(stdout);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
}
