#include <bits/stdc++.h>
using namespace std;
int N;
int K1;
set<int> S1, S2;
int K2;
vector<int> edges[1000010];
set<pair<int, int> > S;
void dfs(int curr, int par, int cnt) {
  if ((S1.find(curr) != S1.end())) {
    S.insert(make_pair(cnt, curr));
  }
  for (int i = 0; i < edges[curr].size(); i++) {
    if (edges[curr][i] != par) {
      dfs(edges[curr][i], curr, cnt + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    S1.clear();
    S2.clear();
    S.clear();
    cin >> N;
    for (int i = 1; i <= N; i++) {
      edges[i].clear();
    }
    for (int i = 1; i < N; i++) {
      int x, y;
      cin >> x >> y;
      edges[x].push_back(y);
      edges[y].push_back(x);
    }
    cin >> K1;
    for (int i = 1; i <= K1; i++) {
      int x;
      cin >> x;
      S1.insert(x);
    }
    cin >> K2;
    for (int i = 1; i <= K2; i++) {
      int x;
      cin >> x;
      S2.insert(x);
    }
    cout << "B " << *(S2.begin()) << endl;
    fflush(stdout);
    int which;
    cin >> which;
    if ((S1.find(which) != S1.end())) {
      cout << "C " << which << endl;
      fflush(stdout);
    } else {
      dfs(which, which, 0);
      int okay = (*(S.begin())).second;
      cout << "A " << okay << endl;
      fflush(stdout);
      cin >> which;
      if ((S2.find(which) != S2.end())) {
        cout << "C " << okay << endl;
        fflush(stdout);
      } else {
        cout << "C -1" << endl;
        fflush(stdout);
      }
    }
  }
  return 0;
}
