#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 10;
const int INF = 1e9;
const int MOD = 998244353;
vector<vector<int>> g;
bool mine[MAXN];
int ask(char c, int node) {
  cout << c << " " << node << endl;
  int ans;
  cin >> ans;
  if (ans == -1) {
    exit(0);
  }
  return ans;
}
int closest;
bool find_closest(int u, int p = -1) {
  if (mine[u]) {
    closest = u;
    return true;
  }
  for (int v : g[u]) {
    if (v != p) {
      if (find_closest(v, u)) return true;
    }
  }
  return false;
}
void response(int x) { cout << "C " << x << endl; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    g.assign(n + 1, {});
    for (int i = 1; i < n; i++) {
      int a, b;
      cin >> a >> b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    memset(mine, 0, sizeof mine);
    int M;
    cin >> M;
    for (int i = 0; i < M; i++) {
      int x;
      cin >> x;
      mine[x] = 1;
    }
    int K;
    cin >> K;
    set<int> other;
    for (int i = 0; i < K; i++) {
      int x;
      cin >> x;
      other.insert(x);
    }
    int node = *other.rbegin();
    int u = ask('B', node);
    if (mine[u])
      response(u);
    else {
      closest = -1;
      find_closest(u);
      assert(closest != -1);
      u = ask('A', closest);
      if (other.count(u)) {
        u = ask('B', u);
        response(u);
      } else {
        response(-1);
      }
    }
  }
  return 0;
}
