#include <bits/stdc++.h>
using namespace std;
int H[1000], M[1000], P[1000], Lim[1000];
vector<vector<int> > edges(1000);
queue<int> Q;
void fill(int n) {
  for (int i = 0; i < n; i++) {
    H[i] = 0;
    M[i] = 0;
    P[i] = 0;
    Lim[i] = 0;
  }
}
void bfs() {
  while (!Q.empty()) {
    int a = Q.front();
    Q.pop();
    int n = edges[a].size();
    for (int i = 0; i < n; i++)
      if (M[edges[a][i]] == 0) {
        M[edges[a][i]] = 1;
        H[edges[a][i]] = H[a] + 1;
        P[edges[a][i]] = P[a];
        Q.push(edges[a][i]);
      }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    fill(n);
    for (int i = 1; i < n; i++) {
      int x, y;
      cin >> x >> y;
      edges[x - 1].push_back(y - 1);
      edges[y - 1].push_back(x - 1);
    }
    int k1, k2;
    cin >> k1;
    for (int i = 0; i < k1; i++) {
      int x;
      cin >> x;
      M[x - 1] = 1;
      P[x - 1] = x - 1;
      Q.push(x - 1);
    }
    bfs();
    cin >> k2;
    int minil = 1001;
    for (int i = 0; i < k2; i++) {
      int x;
      cin >> x;
      Lim[x - 1] = 1;
      minil = min(minil, x - 1);
    }
    cout << "B " << minil + 1 << "\n";
    int response;
    cin >> response;
    if (response == -1) exit(0);
    response--;
    if (H[response] >= k2) {
      cout << "C -1\n";
    } else if (H[response] == 0) {
      cout << "C " << response + 1 << "\n";
    } else {
      cout << "A " << P[response] + 1 << "\n";
      int response1;
      cin >> response1;
      if (response1 == -1) exit(0);
      response1--;
      if (Lim[response1] == 1)
        cout << "C " << P[response] + 1 << "\n";
      else
        cout << "C -1\n";
    }
    cout.flush();
    for (int i = 0; i < n; i++) edges[i].clear();
  }
  return 0;
}
