#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 5;
vector<int> graph[MAXN];
bool vis[MAXN];
int n;
void init() {
  for (int i = 1; i <= n; i++) {
    graph[i].clear();
    vis[i] = false;
  }
}
int arr1[MAXN], arr2[MAXN];
int dfs(int u, int pre = -1) {
  if (vis[u]) {
    return u;
  }
  for (int i = 0; i < graph[u].size(); i++) {
    int v = graph[u][i];
    if (v == pre) {
      continue;
    }
    int tmp = dfs(v, u);
    if (tmp) {
      return tmp;
    }
  }
  return 0;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    init();
    for (int i = 0; i < n - 1; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    int k1, k2;
    scanf("%d", &k1);
    for (int i = 1; i <= k1; i++) {
      scanf("%d", &arr1[i]);
      vis[arr1[i]] = true;
    }
    scanf("%d", &k2);
    for (int i = 1; i <= k2; i++) {
      scanf("%d", &arr2[i]);
    }
    printf("B %d\n", arr2[1]);
    fflush(stdout);
    int u1;
    scanf("%d", &u1);
    int tmp = dfs(u1);
    printf("A %d\n", tmp);
    fflush(stdout);
    scanf("%d", &u1);
    bool yes = false;
    for (int i = 1; i <= k2; i++) {
      if (arr2[i] == u1) {
        yes = true;
        break;
      }
    }
    if (yes) {
      printf("C %d\n", tmp);
    } else {
      printf("C -1\n");
    }
    fflush(stdout);
  }
  return 0;
}
