#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const long long INF = 1e18;
const long double EPS = 1e-12;
vector<vector<int> > adj;
int vi[1005];
int pp[1005];
int qq[1005];
queue<int> qu;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    adj.resize(0);
    adj.resize(n + 5);
    for (int i = (int)1; i < (int)n + 1; i++) vi[i] = 0;
    for (int i = (int)1; i < (int)n + 1; i++) pp[i] = 0;
    for (int i = (int)1; i < (int)n + 1; i++) qq[i] = 0;
    for (int i = 0; i < (int)n - 1; i++) {
      int x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    int a, b;
    cin >> a;
    for (int i = 0; i < (int)a; i++) {
      int x;
      cin >> x;
      pp[x] = 1;
    }
    int tmp;
    cin >> b;
    for (int j = 0; j < (int)b; j++) {
      int x;
      cin >> x;
      qq[x] = 1;
      tmp = x;
    }
    cout << "B " << tmp << endl;
    fflush(stdout);
    int x;
    cin >> x;
    if (pp[x] == 1) {
      cout << "C " << x << endl;
      fflush(stdout);
      continue;
    }
    vi[x] = 1;
    while (not qu.empty()) qu.pop();
    qu.push(x);
    int fl = 0;
    int xx = x;
    while (not qu.empty()) {
      int u = qu.front();
      qu.pop();
      for (int j = 0; j < (int)adj[u].size(); j++) {
        int v = adj[u][j];
        if (not vi[v]) {
          vi[v] = 1;
          qu.push(v);
          if (pp[v] == 1) {
            xx = v;
            fl = 1;
            break;
          }
        }
      }
      if (fl == 1) {
        break;
      }
    }
    cout << "A " << xx << endl;
    fflush(stdout);
    int yy;
    cin >> yy;
    if (qq[yy] == 1) {
      cout << "C " << xx << endl;
    } else {
      cout << "C -1" << endl;
    }
  }
  return 0;
}
