#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
const int mod = 998244353;
int t, n, A[1010], B[1010], vis[1010];
vector<int> adj[1010];
void solve() {
  cin >> n;
  for (int i = 1; i < 1010; i++) adj[i].clear();
  memset(A, 0, sizeof A);
  memset(B, 0, sizeof B);
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    int a;
    cin >> a;
    A[a] = true;
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    int a;
    cin >> a;
    B[a] = true;
  }
  for (int i = 1; i <= n; i++)
    if (B[i]) {
      cout << "B " << i << endl;
      break;
    }
  int st;
  cin >> st;
  queue<int> Q;
  Q.push(st);
  while ((int)Q.size()) {
    int v = Q.front();
    Q.pop();
    if (A[v]) {
      cout << "A " << v << endl;
      cin >> st;
      if (B[st])
        cout << "C " << v << endl;
      else
        cout << "C -1" << endl;
      break;
    }
    for (int to : adj[v])
      if (!vis[to]) {
        vis[to] = true;
        Q.push(to);
      }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  cin >> t;
  while (t--) solve();
  return 0;
}
