#include <bits/stdc++.h>
using namespace std;
const long long LLMAX = 2e18;
const int MOD = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 1e6 + 10;
const int hmod1 = 0x48E2DCE7;
const int hmod2 = 0x60000005;
inline long long sqr(long long x) { return x * x; }
inline int sqr(int x) { return x * x; }
inline double sqr(double x) { return x * x; }
long long __gcd(long long a, long long b) {
  return b == 0 ? a : __gcd(b, a % b);
}
long long qpow(long long a, long long n) {
  long long sum = 1;
  while (n) {
    if (n & 1) sum = sum * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return sum;
}
inline int dcmp(double x) {
  if (fabs(x) < eps) return 0;
  return (x > 0 ? 1 : -1);
}
int head[MAXN], cnt, mark1[MAXN], mark2[MAXN];
struct Edge {
  int to, next;
} edge[MAXN];
void init(int n) {
  cnt = 0;
  for (int i = 0; i <= n; i++) {
    head[i] = -1;
    mark1[i] = 0;
    mark2[i] = 0;
  }
}
void addedge(int u, int v) {
  edge[cnt].to = v;
  edge[cnt].next = head[u];
  head[u] = cnt++;
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, x;
    cin >> n;
    init(n);
    for (int i = 1; i < n; i++) {
      int u, v;
      cin >> u >> v;
      addedge(u, v), addedge(v, u);
    }
    int k1;
    cin >> k1;
    for (int i = 0; i < k1; i++) cin >> x, mark1[x] = 1;
    int k2;
    cin >> k2;
    for (int i = 0; i < k2; i++) cin >> x, mark2[x] = 1;
    cout << "B " << x << endl;
    cout.flush();
    int id;
    cin >> id;
    queue<int> q;
    q.push(id);
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      if (mark1[u] == 1) {
        id = u;
        break;
      }
      mark1[u] = -1;
      for (int i = head[u]; ~i; i = edge[i].next) {
        int v = edge[i].to;
        if (mark1[v] != -1) q.push(v);
      }
    }
    cout << "A " << id << endl;
    cout.flush();
    int now;
    cin >> now;
    if (mark2[now] == 0) {
      cout << "C -1" << endl;
      cout.flush();
    } else {
      cout << "C " << id << endl;
      cout.flush();
    }
  }
  return 0;
}
