#include <bits/stdc++.h>
using namespace std;
ifstream fin("AAtest.in.txt");
long long t, n, k1, k2, x[1005], y[1005], a, b, boo = -2;
vector<long long> tee[1005];
bool kul[1005];
void rek(long long l) {
  kul[l] = 1;
  if (x[l]) {
    cout << "A " << l << endl;
    cin >> boo;
    if (boo != -1) boo = l;
    return;
  }
  for (int i = 0; i < tee[l].size(); i++)
    if (!kul[tee[l][i]]) {
      rek(tee[l][i]);
      if (boo != -2) return;
    }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> t;
  for (int o = 0; o < t; o++) {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
      cin >> a >> b;
      tee[a].push_back(b);
      tee[b].push_back(a);
    }
    cin >> k1;
    memset(x, 0, sizeof(x));
    memset(y, 0, sizeof(y));
    for (int i = 0; i < k1; i++) cin >> a, x[a] = 1;
    cin >> k2;
    for (int i = 0; i < k2; i++) cin >> a, y[a] = 1;
    cout << "B " << a << endl;
    cin >> a;
    boo = -2;
    memset(kul, 0, sizeof(kul));
    rek(a);
    cout << "C " << boo << endl;
  }
}
