#include <bits/stdc++.h>
using namespace std;
vector<int> g[1005];
int x[1005], y[1005];
int t, n, i, u, v, m, ans, tp;
void dfs(int u, int fa) {
  if (x[u]) {
    cout << "A " << u << endl;
    fflush(stdout);
    cin >> tp;
    if (y[tp])
      ans = u;
    else
      ans = -1;
    return;
  }
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    dfs(v, u);
    if (ans) return;
  }
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (i = 1; i <= n; i++) {
      g[i].clear();
      x[i] = y[i] = 0;
    }
    for (i = 0; i < n - 1; i++) {
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    cin >> m;
    for (i = 0; i < m; i++) {
      cin >> u;
      x[u] = 1;
    }
    cin >> m;
    for (i = 0; i < m; i++) {
      cin >> u;
      y[u] = 1;
    }
    cout << "B " << u << endl;
    fflush(stdout);
    cin >> u;
    ans = 0;
    dfs(u, 0);
    cout << "C " << ans << endl;
    fflush(stdout);
  }
}
