#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T>
constexpr int infValue =
    std::is_same<T, int>::value ? 2000100007 : 8600000000000000007ll;
template <typename T>
constexpr int maxValue =
    std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;
const int INF = infValue<int>;
const long long MOD = 998244353ll;
const double EPS = 1e-6;
const int MAX = maxValue<int>;
using pr = pair<int, int>;
int t, n;
vector<int> g[1001];
bool u[1001], v[1001];
int answ = -1;
void dfs(int p, int r = -1) {
  if (u[p] && answ == -1) {
    answ = p;
  }
  for (const int &to : g[p]) {
    if (to != r) {
      dfs(to, p);
    }
  }
}
int getA(int x) {
  printf("A %d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  return x;
}
int getB(int x) {
  printf("B %d\n", x);
  fflush(stdout);
  scanf("%d", &x);
  return x;
}
int main(void) {
  scanf("%d", &t);
  while (t--) {
    answ = -1;
    for (register int i = 1; i < 1001; ++i) g[i].clear(), u[i] = v[i] = false;
    scanf("%d", &n);
    for (register int i = 0; i < n - 1; ++i) {
      int a, b;
      scanf("%d %d", &a, &b);
      g[a].push_back(b);
      g[b].push_back(a);
    }
    int k, a;
    scanf("%d", &k);
    while (k--) {
      scanf("%d", &a);
      u[a] = true;
    }
    scanf("%d", &k);
    while (k--) {
      scanf("%d", &a);
      v[a] = true;
    }
    dfs(getB(a));
    int x = getA(answ);
    printf("C %d\n", v[x] ? answ : -1);
    fflush(stdout);
  }
  return 0;
}
