#include <bits/stdc++.h>
using namespace std;
vector<int> v[1007], v1, v2;
bool vis1[1007], vis2[1007];
int t, n, n1, n2;
int dfs(int x) {
  queue<int> q;
  bool vis[1007];
  memset(vis, false, sizeof(vis));
  q.push(x);
  while (!q.empty()) {
    x = q.front();
    q.pop();
    if (vis1[x]) {
      return x;
    }
    vis[x] = true;
    for (int i = 0; i < v[x].size(); i++) {
      if (!vis[v[x][i]]) {
        vis[v[x][i]] = true;
        q.push(v[x][i]);
      }
    }
  }
}
int main() {
  scanf("%d", &t);
  while (t--) {
    memset(vis1, false, sizeof(vis1));
    memset(vis2, false, sizeof(vis2));
    v1.clear();
    v2.clear();
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) v[i].clear();
    int x, y;
    while (--n) {
      scanf("%d%d", &x, &y);
      v[x].push_back(y);
      v[y].push_back(x);
    }
    scanf("%d", &n1);
    int a;
    for (int i = 0; i < n1; i++) {
      scanf("%d", &a);
      vis1[a] = true;
      v1.push_back(a);
    }
    scanf("%d", &n2);
    for (int i = 0; i < n2; i++) {
      scanf("%d", &a);
      vis2[a] = true;
      v2.push_back(a);
    }
    printf("B %d\n", v2[0]);
    fflush(stdout);
    scanf("%d", &a);
    if (vis1[a]) {
      printf("C %d\n", a);
      fflush(stdout);
    } else {
      a = dfs(a);
      int a11 = a;
      printf("A %d\n", a);
      fflush(stdout);
      scanf("%d", &a);
      if (vis2[a]) {
        printf("C %d\n", a);
        fflush(stdout);
      } else {
        printf("C %d\n", -1);
        fflush(stdout);
      }
    }
  }
  return 0;
}
