#include <bits/stdc++.h>
using namespace std;
void Solve(int n, vector<vector<int> > &neigh, int k1, vector<int> &x1, int k2,
           vector<int> &x2) {
  vector<bool> is_my(n, false), is_his(n, false);
  for (int i = 0; i < k1; i++) is_my[x1[i]] = true;
  for (int i = 0; i < k2; i++) is_his[x2[i]] = true;
  cout << "B " << x2[0] + 1 << endl;
  int start;
  cin >> start;
  start--;
  queue<int> index;
  vector<bool> is_visited(n, false);
  index.push(start);
  is_visited[start] = true;
  int finish = -1;
  while (!index.empty()) {
    int a = index.front();
    if (is_my[a]) {
      finish = a;
      break;
    }
    for (auto b : neigh[a])
      if (!is_visited[b]) {
        is_visited[b] = true;
        index.push(b);
      }
    index.pop();
  }
  cout << "A " << finish + 1 << endl;
  int ans;
  cin >> ans;
  ans--;
  if (is_his[ans])
    cout << "C " << finish + 1 << endl;
  else
    cout << "C " << -1 << endl;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    vector<vector<int> > neigh(n);
    for (int j = 0; j < n - 1; j++) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      neigh[a].push_back(b);
      neigh[b].push_back(a);
    }
    int k1;
    cin >> k1;
    vector<int> x1(k1);
    for (int j = 0; j < k1; j++) {
      cin >> x1[j];
      x1[j]--;
    }
    int k2;
    cin >> k2;
    vector<int> x2(k2);
    for (int j = 0; j < k2; j++) {
      cin >> x2[j];
      x2[j]--;
    }
    Solve(n, neigh, k1, x1, k2, x2);
  }
}
