#include <bits/stdc++.h>
using namespace std;
struct node {
  int v, nxt;
};
node edge[100001];
int n, t, head[100001], depth[100001], len, k1, t1[100001], k2, t2[100001];
void add(int x, int y) {
  edge[++len].v = y, edge[len].nxt = head[x], head[x] = len;
  edge[++len].v = x, edge[len].nxt = head[y], head[y] = len;
  return;
}
int read() {
  char c = 0;
  int sum = 0;
  while (c < '0' || c > '9') c = getchar();
  while ('0' <= c && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
bool used[100001];
void dfs(int x) {
  used[x] = 1;
  for (int i = head[x]; i > 0; i = edge[i].nxt)
    if (!used[edge[i].v]) depth[edge[i].v] = depth[x] + 1, dfs(edge[i].v);
  return;
}
int main() {
  bool op;
  int x, y, s, minn = 1e9, miner;
  t = read();
  while (t--) {
    op = len = 0;
    n = read();
    for (int i = 1; i <= n; ++i) head[i] = depth[i] = used[i] = 0;
    for (int i = 1; i <= n - 1; ++i) {
      x = read(), y = read();
      add(x, y);
    }
    k1 = read();
    for (int i = 1; i <= k1; ++i) t1[i] = read();
    k2 = read();
    for (int i = 1; i <= k2; ++i) t2[i] = read();
    printf("B %d\n", t2[1]);
    fflush(stdout);
    s = read();
    dfs(s);
    minn = 1e9;
    for (int i = 1; i <= k1; ++i)
      if (depth[t1[i]] < minn) minn = depth[t1[i]], miner = t1[i];
    printf("A %d\n", miner);
    fflush(stdout);
    s = read();
    for (int i = 1; i <= k2; ++i)
      if (t2[i] == s) {
        op = 1;
        printf("C %d\n", miner);
        break;
      }
    if (!op) puts("C -1");
    fflush(stdout);
  }
  return 0;
}
