#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double pi = acos(-1.0);
const int maxn = 100000 + 10;
const int mod = 1e9 + 7;
inline char _getchar() {
  static const int BUFSIZE = 100001;
  static char buf[BUFSIZE];
  static char *psta = buf, *pend = buf;
  if (psta >= pend) {
    psta = buf;
    pend = buf + fread(buf, 1, BUFSIZE, stdin);
    if (psta >= pend) return -1;
  }
  return *psta++;
}
void dfs(int x, int fa, vector<vector<int> > &g, vector<int> &p,
         vector<int> &vis) {
  for (int i = 0; i < g[x].size(); i++) {
    if (g[x][i] != fa && !vis[g[x][i]]) {
      p[g[x][i]] = p[x];
      dfs(g[x][i], x, g, p, vis);
    }
  }
}
void gao(int n) {
  vector<vector<int> > g;
  vector<int> p;
  vector<int> vis;
  g.resize(n + 2);
  p.resize(n + 2);
  vis.resize(n + 2);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d", &u), scanf("%d", &v);
    g[u].push_back(v), g[v].push_back(u);
  }
  int k1;
  scanf("%d", &k1);
  for (int i = 0; i < k1; i++) {
    int u;
    scanf("%d", &u);
    vis[u] = 1;
    p[u] = u;
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) dfs(i, 0, g, p, vis);
  }
  int k2;
  scanf("%d", &k2);
  vector<int> q(k2);
  for (int i = 0; i < k2; i++) {
    scanf("%d", &q[i]);
  }
  sort(q.begin(), q.end());
  printf("B %d\n", q[0]);
  fflush(stdout);
  int id;
  scanf("%d", &id);
  printf("A %d\n", p[id]);
  fflush(stdout);
  int ret;
  scanf("%d", &ret);
  int w = lower_bound(q.begin(), q.end(), ret) - q.begin();
  if (w != q.size() && q[w] == ret)
    printf("C %d\n", p[id]), fflush(stdout);
  else
    printf("C -1\n"), fflush(stdout);
}
int main() {
  int T;
  scanf("%d", &T);
  for (int cas = 1; cas <= T; cas++) {
    int n;
    scanf("%d", &n);
    gao(n);
  }
  return 0;
}
