#include <bits/stdc++.h>
using namespace std;
vector<int> AdjList[1005];
int T, N, Ka, Kb, X, Y, v1, v2, v3, ans;
vector<int> A, B;
int marked1[1005], marked2[1005], track[1005];
void res() {
  A.clear();
  B.clear();
  for (int i = 1; i <= 1000; ++i) {
    AdjList[i].clear();
    marked1[i] = marked2[i] = 0;
  }
}
void dfs(int x, int p, int v) {
  track[x] = v;
  for (auto it : AdjList[x]) {
    if (it == p) continue;
    if (marked1[x])
      dfs(it, x, x);
    else
      dfs(it, x, v);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> T;
  for (int t = 1; t <= T; ++t) {
    cin >> N;
    res();
    for (int i = 1; i < N; ++i) {
      cin >> X >> Y;
      AdjList[X].push_back(Y);
      AdjList[Y].push_back(X);
    }
    cin >> Ka;
    for (int i = 1; i <= Ka; ++i) {
      cin >> X;
      A.push_back(X);
      marked1[X] = 1;
    }
    cin >> Kb;
    for (int i = 1; i <= Kb; ++i) {
      cin >> X;
      B.push_back(X);
      marked2[X] = 1;
    }
    dfs(A[0], -1, A[0]);
    cout << "B " << B[0] << '\n' << flush;
    cin >> v1;
    if (marked1[v1]) {
      cout << "C " << v1 << '\n' << flush;
      continue;
    }
    v2 = track[v1];
    cout << "A " << v2 << '\n' << flush;
    cin >> v3;
    if (!marked2[v3]) {
      cout << "C " << -1 << '\n' << flush;
    } else {
      cout << "C " << v2 << '\n' << flush;
    }
  }
}
