#include <bits/stdc++.h>
clock_t t_;
using namespace std;
int main(int argc, const char* argv[]) {
  t_ = clock();
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> edges[1010];
    int a, b;
    for (int i = int(0); i < int(n - 1); i++) {
      cin >> a >> b;
      edges[a].push_back(b);
      edges[b].push_back(a);
    }
    int k1;
    cin >> k1;
    set<int> xs;
    for (int i = int(0); i < int(k1); i++) {
      cin >> a;
      xs.insert(a);
    }
    int k2;
    set<int> ys;
    cin >> k2;
    for (int i = int(0); i < int(k2); i++) {
      cin >> a;
      ys.insert(a);
    }
    int resp;
    cout << "B " << a << endl;
    cout << flush;
    cin >> resp;
    if (xs.find(resp) != xs.end()) {
      cout << "C " << resp << endl;
      cout << flush;
    } else {
      queue<int> q;
      vector<int> dist(n + 7, -1);
      q.push(resp);
      dist[resp] = 0;
      while (xs.find(q.front()) == xs.end()) {
        int fr = q.front();
        q.pop();
        for (int i = int(0); i < int(edges[fr].size()); i++) {
          int to = edges[fr][i];
          if (dist[to] == -1) {
            dist[to] = dist[fr] + 1;
            q.push(to);
          }
        }
      }
      a = q.front();
      cout << "A " << a << endl;
      cout << flush;
      cin >> resp;
      if (ys.find(resp) != ys.end()) {
        cout << "C " << a << endl;
        cout << flush;
      } else {
        cout << "C " << -1 << endl;
        cout << flush;
      }
    }
  }
  t_ = clock() - t_;
  cerr << setprecision(9) << fixed << ((float)t_ / CLOCKS_PER_SEC) << endl;
  return 0;
}
