#include <bits/stdc++.h>
using namespace std;
inline int ask(char p, int v) {
  int ret;
  printf("%c %d\n", p, v);
  fflush(stdout);
  scanf("%d", &ret);
  return ret;
}
inline void ans(int v) {
  printf("C %d\n", v);
  fflush(stdout);
}
int n;
vector<int> adj[1005];
void read(vector<int> &x, vector<int> &y) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) adj[i].clear();
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int k1, k2;
  scanf("%d", &k1);
  x.resize(k1);
  for (int i = 0; i < k1; i++) scanf("%d", &x[i]);
  scanf("%d", &k2);
  y.resize(k2);
  for (int i = 0; i < k2; i++) scanf("%d", &y[i]);
}
bool inX[1005];
bool inY[1005];
bool vis[1005];
int Main() {
  vector<int> x, y;
  read(x, y);
  fill(inX + 1, inX + n + 1, 0);
  fill(inY + 1, inY + n + 1, 0);
  fill(vis + 1, vis + n + 1, 0);
  for (int u : x) inX[u] = 1;
  for (int u : y) inY[u] = 1;
  int check = ask('B', y[0]);
  if (inX[check]) {
    ans(check);
    return 0;
  }
  queue<int> q;
  q.push(check);
  vis[check] = 1;
  int ret = -1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (inX[u]) {
      ret = u;
      while (!q.empty()) q.pop();
      break;
    }
    for (int nx : adj[u])
      if (!vis[nx]) vis[nx] = 1, q.push(nx);
  }
  check = ask('A', ret);
  if (!inY[check])
    ans(-1);
  else
    ans(ret);
  return 0;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) Main();
  return 0;
}
