#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> dsk[10005];
long long a, b;
long long incl1[10005], incl2[10005];
bool vs[10005];
long long BFS(long long u) {
  if (incl1[u]) {
    return u;
  }
  vs[u] = 1;
  deque<long long> Q = {u};
  while (!Q.empty()) {
    long long v = Q.front();
    Q.pop_front();
    for (long long i = 0; i < dsk[v].size(); i++) {
      long long w = dsk[v][i];
      if (incl1[w]) {
        return w;
      }
      if (vs[w]) {
        continue;
      }
      vs[w] = 1;
      Q.push_back(w);
    }
  }
  return u;
}
void input() {
  cin >> n;
  long long x, y;
  for (long long i = 1; i < n; i++) {
    cin >> x >> y;
    dsk[x].push_back(y);
    dsk[y].push_back(x);
  }
  cin >> a;
  for (long long i = 1; i <= a; i++) {
    cin >> x;
    incl1[x] = 1;
  }
  cin >> b;
  for (long long i = 1; i <= b; i++) {
    cin >> x;
    incl2[x] = 1;
  }
  return;
}
void solve() {
  long long t;
  for (long long i = 1; i <= n; i++) {
    if (incl2[i]) {
      cout << "B " << i << endl;
      break;
    }
  }
  cin >> t;
  t = BFS(t);
  long long x;
  cout << "A " << t << endl;
  cin >> x;
  if (x == -1) {
    exit(0);
  }
  if (incl2[x]) {
    cout << "C " << t << endl;
    return;
  } else {
    cout << "C -1" << endl;
    return;
  }
}
void output() { return; }
signed main() {
  ios_base::sync_with_stdio(false);
  long long t;
  cin >> t;
  for (long long i = 1; i <= t; i++) {
    for (long long j = 1; j <= 1000; j++) {
      incl1[j] = incl2[j] = vs[j] = 0;
      dsk[j].clear();
    }
    input();
    solve();
    output();
  }
  return 0;
}
