#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005, maxm = 200005;
struct Node {
  int v;
  Node *next;
} * h[maxn], pool[maxm];
int tot;
void addEdge(int u, int v) {
  Node *p = &pool[++tot];
  p->v = v;
  p->next = h[u];
  h[u] = p;
}
int n, k1, k2;
int me[maxn], le[maxn];
int x[maxn], y[maxn];
int q[maxn], head, tail, vis[maxn];
void reset() {
  memset(h, NULL, sizeof(h));
  memset(x, 0, sizeof(x));
  memset(y, 0, sizeof(y));
  tot = 0;
}
int find(int pre) {
  memset(vis, 0, sizeof(vis));
  head = tail = 0;
  q[tail++] = pre;
  vis[pre] = 1;
  while (head < tail) {
    int u = q[head++];
    if (x[u] == 1) return u;
    for (Node *p = h[u]; p; p = p->next) {
      if (vis[p->v] == 0) {
        vis[p->v] = 1;
        q[tail++] = p->v;
      }
    }
  }
  return -1;
}
void work() {
  int tp = le[1];
  cout << "B " << tp << endl;
  fflush(stdout);
  int rsp;
  cin >> rsp;
  if (rsp == -1) exit(0);
  if (x[rsp] == 1) {
    cout << "C " << rsp << endl;
    return;
  }
  int fp = find(rsp);
  cout << "A " << fp << endl;
  fflush(stdout);
  cin >> rsp;
  if (rsp == -1) exit(0);
  if (y[rsp] == 1)
    cout << "C " << fp << endl;
  else
    cout << "C -1" << endl;
  return;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    reset();
    cin >> n;
    for (int i = 1; i <= n - 1; i++) {
      int x, y;
      cin >> x >> y;
      addEdge(x, y);
      addEdge(y, x);
    }
    cin >> k1;
    for (int i = 1; i <= k1; i++) {
      cin >> me[i];
      x[me[i]] = 1;
    }
    cin >> k2;
    for (int i = 1; i <= k2; i++) {
      cin >> le[i];
      y[le[i]] = 1;
    }
    work();
  }
  return 0;
}
