#include <bits/stdc++.h>
using namespace std;
vector<int> g[2005], dis(2005), a(2005);
void dfs(int a, int p) {
  for (int i = 0; i < g[a].size(); i++) {
    int y = g[a][i];
    if (y == p) continue;
    dis[y] = dis[a] + 1;
    dfs(y, a);
  }
}
int ask(int a, int b) {
  int ans;
  if (a == 0) {
    cout << "B " << b << "\n";
  } else
    cout << "A " << b << "\n";
  fflush(stdout);
  cin >> ans;
  if (ans == -1) exit(0);
  return ans;
}
void clean(int n) {
  for (int i = 0; i <= n; i++) {
    g[i].clear();
    dis[i] = 0;
    a[i] = 0;
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    clean(n);
    for (int i = 0; i < n - 1; i++) {
      int u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    int k1, k2;
    cin >> k1;
    for (int i = 1; i <= k1; i++) {
      int x;
      cin >> x;
      a[x] = 1;
    }
    cin >> k2;
    int x;
    map<int, int> mp;
    for (int i = 1; i <= k2; i++) {
      int b;
      cin >> b;
      mp[b];
      x = b;
    }
    x = ask(0, x);
    int mn = 9999999;
    dis[x] = 0;
    dfs(x, 0);
    int y;
    for (int i = 1; i <= n; i++)
      if (dis[i] < mn && a[i]) {
        mn = dis[i];
        y = i;
      }
    int z = ask(1, y);
    if (mp.find(z) == mp.end()) {
      cout << "C " << -1 << "\n";
    } else
      cout << "C " << y << "\n";
    fflush(stdout);
  }
  return 0;
}
