#include <bits/stdc++.h>
using namespace std;
int tc, n, k1, k2;
int mark1[1005], mark2[1005];
vector<int> E[1005];
int dfs(int u, int par) {
  if (mark1[u]) return u;
  for (int v : E[u]) {
    if (v == par) continue;
    int ans = dfs(v, u);
    if (ans) return ans;
  }
  return 0;
}
int main() {
  scanf("%d", &tc);
  while (tc--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      E[i].clear();
      mark1[i] = mark2[i] = false;
    }
    for (int i = 0; i < n - 1; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      E[u].push_back(v);
      E[v].push_back(u);
    }
    scanf("%d", &k1);
    for (int i = 1; i <= k1; i++) {
      int u;
      scanf("%d", &u);
      mark1[u] = true;
    }
    scanf("%d", &k2);
    for (int i = 1; i <= k2; i++) {
      int u;
      scanf("%d", &u);
      mark2[u] = true;
    }
    for (int i = 1; i <= n; i++) {
      if (mark2[i]) {
        printf("B %d\n", i);
        fflush(stdout);
        int u;
        scanf("%d", &u);
        int x = dfs(u, -1);
        printf("A %d\n", x);
        fflush(stdout);
        int v;
        scanf("%d", &v);
        if (mark2[v]) {
          printf("C %d\n", x);
        } else {
          printf("C -1\n");
        }
        fflush(stdout);
        break;
      }
    }
  }
  return 0;
}
