#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e, z[1009], x[1009], tes, t, zi, xi, la[1009], za, m[1009];
vector<int> v[1009];
void dfs(int q, int w) {
  if (la[q] == 1) {
    za = q;
    return;
  }
  for (vector<int>::iterator it = v[q].begin(); it != v[q].end(); it++) {
    if ((*it) == w) continue;
    dfs((*it), q);
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> tes;
  for (t = 1; t <= tes; t++) {
    cin >> a;
    for (b = 1; b <= 1000; b++) v[b].clear();
    for (b = 1; b < a; b++) {
      cin >> c >> d;
      v[c].push_back(d);
      v[d].push_back(c);
    }
    cin >> zi;
    for (b = 1; b <= zi; b++) cin >> z[b];
    for (b = 1; b <= 1000; b++) {
      la[b] = 0;
      m[b] = 0;
    }
    for (b = 1; b <= zi; b++) la[z[b]] = 1;
    cin >> xi;
    for (b = 1; b <= xi; b++) cin >> x[b];
    for (b = 1; b <= xi; b++) m[x[b]] = 1;
    cout << "B " << x[1];
    cout << endl;
    fflush(stdout);
    cin >> c;
    za = -1;
    dfs(c, 0);
    cout << "A " << za;
    cout << endl;
    fflush(stdout);
    cin >> c;
    if (m[c] == 0) za = -1;
    cout << "C " << za;
    cout << endl;
    fflush(stdout);
  }
  return 0;
}
