#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int t, n, a, b, k, c, G;
  cin >> t;
  vector<int> D[1000], T;
  int A[1000], B[1000], g[1000], K[1000];
  for (int i = 0; i < t; i++) {
    cin >> n;
    for (int y = 0; y < n; y++) {
      A[y] = 0;
      B[y] = 0;
      g[y] = 1;
    }
    for (int y = 0; y < n - 1; y++) {
      cin >> a >> b;
      a--;
      b--;
      D[a].push_back(b);
      D[b].push_back(a);
    }
    cin >> k;
    for (int y = 0; y < k; y++) {
      cin >> a;
      a--;
      A[a] = 1;
    }
    cin >> k;
    for (int y = 0; y < k; y++) {
      cin >> K[y];
      K[y]--;
    }
    cout << "B " << K[0] + 1 << endl;
    cin >> c;
    c--;
    T.push_back(c);
    for (int y = 0; y < T.size(); y++) {
      if (A[T[y]] == 1) {
        cout << "A " << T[y] + 1 << endl;
        cin >> c;
        c--;
        G = 0;
        for (int u = 0; u < k; u++) {
          if (K[u] == c) {
            G = 1;
            cout << "C " << T[y] + 1 << endl;
          }
        }
        if (G == 0) {
          cout << "C " << -1 << endl;
        }
        y = T.size() + 1;
      } else {
        for (int u = 0; u < D[T[y]].size(); u++) {
          if (g[D[T[y]][u]] == 1) {
            g[D[T[y]][u]] = 0;
            T.push_back(D[T[y]][u]);
          }
        }
      }
    }
    for (int y = 0; y < 1000; y++) {
      D[y].clear();
    }
    T.clear();
  }
  return 0;
}
