#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5 + 5;
const int inf = 1e9;
vector<int> adj[mxn];
bool f1[mxn], f2[mxn];
bool done;
int ask(char x, int y) {
  cout << x << " " << y << endl;
  int r;
  cin >> r;
  return r;
}
int dfs(int cur, int prev) {
  if (done) return -1;
  if (f1[cur]) {
    done = true;
    int x = ask('A', cur);
    if (f2[x]) return cur;
    return -1;
  }
  for (int u : adj[cur]) {
    if (u == prev) continue;
    int x = dfs(u, cur);
    if (done) return x;
  }
  return -1;
}
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    adj[i].clear();
    f1[i] = false;
    f2[i] = false;
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int k1;
  cin >> k1;
  int x[k1];
  for (int i = 0; i < k1; i++) {
    cin >> x[i];
    f1[x[i]] = true;
  }
  int k2;
  cin >> k2;
  int y[k2];
  for (int i = 0; i < k2; i++) {
    cin >> y[i];
    f2[y[i]] = true;
  }
  done = false;
  int r = ask('B', y[0]);
  cout << "C " << dfs(r, -1) << endl;
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) solve();
}
