#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7, INF = 1e7;
const double PI = 3.141592653589793238462643383279502884197, eps = 1e-6;
vector<int> tree[N];
bool K1[N], K2[N];
int dfs(int ind, int p) {
  if (K1[ind]) return ind;
  int ret = INF;
  for (int i : tree[ind])
    if (i != p) ret = min(ret, dfs(i, ind));
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k1, k2, x, ans;
    cin >> n;
    for (int i = 1; i < n; i++) {
      int u, v;
      cin >> u >> v;
      tree[u].push_back(v);
      tree[v].push_back(u);
    }
    cin >> k1;
    while (k1--) cin >> x, K1[x] = 1;
    cin >> k2;
    while (k2--) cin >> x, K2[x] = 1;
    cout << "B " << x << endl;
    cin >> x;
    ans = x = dfs(x, -1);
    cout << "A " << x << endl;
    cin >> x;
    if (K2[x])
      cout << "C " << ans << endl;
    else
      cout << "C -1" << endl;
    memset(K1, 0, sizeof K1);
    memset(K2, 0, sizeof K2);
    for (int i = 0; i < N; i++) tree[i].clear();
  }
  return 0;
}
