#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
bool istree[1001], istree2[1001];
vector<int> tr1, tr2;
int dfs(int u, int p) {
  if (istree[u]) {
    cout << "A " << u + 1 << endl;
    int q;
    cin >> q;
    if (istree2[q - 1]) return u + 1;
    return -1;
  }
  for (int i = 0; i < g[u].size(); ++i) {
    if (g[u][i] == p) continue;
    int x = dfs(g[u][i], u);
    if (x) return x;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    g.clear();
    g.resize(n + 1);
    tr1.clear();
    tr2.clear();
    memset(istree, 0, sizeof(istree));
    memset(istree2, 0, sizeof(istree2));
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      cin >> a >> b;
      g[--a].push_back(--b);
      g[b].push_back(a);
    }
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
      int x;
      cin >> x;
      istree[--x] = 1;
      tr1.push_back(x);
    }
    cin >> k;
    for (int i = 0; i < k; ++i) {
      int x;
      cin >> x;
      istree2[--x] = 1;
      tr2.push_back(x);
    }
    cout << "B " << tr2[0] + 1 << endl;
    int q;
    cin >> q;
    cout << "C " << dfs(q - 1, -1) << endl;
  }
  return 0;
}
