#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long inf = 1e18;
long long modpow(long long a, long long e) {
  if (e == 0) return 1;
  long long x = modpow(a * a % mod, e >> 1);
  return e & 1 ? x * a % mod : x;
}
int tt;
int n, x, y, pos, k1, k2, m[1009], o[1009], mn, jog;
vector<int> E[1009];
void dfs(int nd, int pr, int dis) {
  if (m[nd] and dis < mn) {
    jog = nd;
    mn = dis;
  }
  for (auto i : E[nd])
    if (i != pr) dfs(i, nd, dis + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> tt;
  while (tt--) {
    cin >> n;
    for (int i = 1; i <= n; i++) m[i] = o[i] = 0, E[i].clear();
    for (int i = 1; i < n; i++) {
      cin >> x >> y;
      E[x].push_back(y);
      E[y].push_back(x);
    }
    cin >> k1;
    for (int i = 1; i <= k1; i++) {
      cin >> x;
      m[x]++;
    }
    cin >> k2;
    for (int i = 1; i <= k2; i++) {
      cin >> x;
      o[x] = 1;
      pos = x;
    }
    cout << "B " << pos << endl;
    cin >> pos;
    mn = mod;
    dfs(pos, 0, 0);
    cout << "A " << jog << endl;
    cin >> pos;
    if (o[pos])
      cout << "C " << jog << endl;
    else
      cout << "C -1" << endl;
  }
}
