#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 1e3 + 7;
const int maxm = 1e5 + 7;
const int mod = 998244353;
int t, n;
int x, y;
int k1, k2;
int subtreex[maxn], subtreey[maxn];
vector<int> tree[maxn];
void init() {
  memset(subtreey, 0, sizeof(subtreey));
  memset(subtreex, 0, sizeof(subtreex));
  for (int i = 0; i < maxn; i++) tree[i].clear();
}
int dfs(int cur, int lst) {
  if (subtreex[cur]) return cur;
  for (int i = 0; i < tree[cur].size(); i++) {
    int v = tree[cur][i];
    if (v == lst) continue;
    int idx = dfs(v, cur);
    if (idx != -1) return idx;
  }
  return -1;
}
int main(int argc, char const *argv[]) {
  scanf("%d", &t);
  while (t--) {
    init();
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      tree[u].push_back(v);
      tree[v].push_back(u);
    }
    scanf("%d", &k1);
    for (int i = 1; i <= k1; i++) {
      scanf("%d", &x);
      subtreex[x] = 1;
    }
    scanf("%d", &k2);
    for (int i = 1; i <= k2; i++) {
      scanf("%d", &y);
      subtreey[y] = 1;
    }
    printf("B %d\n", y);
    fflush(stdout);
    int yinx;
    scanf("%d", &yinx);
    if (subtreex[yinx]) {
      printf("C %d\n", yinx);
      fflush(stdout);
      continue;
    }
    int idx = dfs(yinx, 0);
    if (idx == -1) {
      printf("C -1\n");
      fflush(stdout);
      continue;
    }
    int p;
    printf("A %d\n", idx);
    fflush(stdout);
    scanf("%d", &p);
    printf("C %d\n", subtreey[p] ? idx : -1);
    fflush(stdout);
  }
  return 0;
}
