#include <bits/stdc++.h>
using namespace std;
long long t, n;
vector<long long> dsk[1005];
vector<long long> Y, L;
set<long long> sY, sL;
long long H[1005], par[1005];
void dfsinit_(long long u) {
  for (long long i : dsk[u])
    if (i != par[u]) {
      par[i] = u;
      H[i] = H[u] + 1;
      dfsinit_(i);
    }
}
signed main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (long long i = 0; i < 1005; i++) dsk[i].clear(), H[i] = 1, par[i] = -1;
    Y.clear(), L.clear(), sY.clear(), sL.clear();
    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);
    }
    long long k;
    cin >> k;
    for (long long i = 0; i < k; i++) {
      cin >> x;
      Y.push_back(x), sY.insert(x);
    }
    cin >> k;
    for (long long i = 0; i < k; i++) {
      cin >> x;
      L.push_back(x), sL.insert(x);
    }
    dfsinit_(1);
    long long t;
    cout << "B " << L[0] << endl;
    cin >> t;
    if (sY.count(t) == 1) {
      cout << "C " << t << endl;
      continue;
    }
    y = t;
    x = Y[0];
    for (long long i = 1; i < Y.size(); i++)
      if (H[x] > H[Y[i]]) x = Y[i];
    cout << "A " << x << endl;
    cin >> t;
    if (sL.count(t) == 1) {
      cout << "C " << x << endl;
      continue;
    }
    x = -1;
    while (y != -1) {
      if (sY.count(y) == 1) {
        x = y;
        break;
      }
      y = par[y];
    }
    if (x == -1) {
      cout << "C -1" << endl;
      continue;
    }
    cout << "A " << x << endl;
    cin >> t;
    if (sL.count(t) == 0)
      cout << "C -1" << endl;
    else
      cout << "C " << x << endl;
  }
  exit(0);
}
