#include <bits/stdc++.h>
using namespace std;
int T;
int N;
vector<int> G[1005];
bool x[1005], y[1005];
bool vis[1005];
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) G[i].clear();
    int a, b;
    for (int i = 1; i < N; i++) {
      scanf("%d %d", &a, &b);
      G[a].push_back(b);
      G[b].push_back(a);
    }
    memset(x, 0, sizeof(x));
    memset(y, 0, sizeof(y));
    int k, xi, yi;
    scanf("%d", &k);
    for (int i = 0; i < k; i++) {
      scanf("%d", &xi);
      x[xi] = true;
    }
    scanf("%d", &k);
    for (int i = 0; i < k; i++) {
      scanf("%d", &yi);
      y[yi] = true;
    }
    int q;
    printf("B %d\n", yi);
    fflush(stdout);
    scanf("%d", &q);
    queue<int> Q;
    Q.push(q);
    memset(vis, 0, sizeof(vis));
    while (!Q.empty()) {
      int cur = Q.front();
      Q.pop();
      if (x[cur]) {
        printf("A %d\n", cur);
        fflush(stdout);
        scanf("%d", &q);
        if (y[q])
          printf("C %d\n", cur);
        else
          puts("C -1");
        fflush(stdout);
        break;
      }
      vis[cur] = true;
      for (int i = 0; i < (int)G[cur].size(); i++) {
        int nxt = G[cur][i];
        if (!vis[nxt]) Q.push(nxt);
      }
    }
  }
  return 0;
}
