#include <bits/stdc++.h>
using namespace std;
mt19937 rng(time(NULL));
void get_ans() {
  vector<int> g[1000];
  set<int> a, b;
  int n, k, s, q[1000], head = 0, tail = 0, p[1000];
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int first, second;
    cin >> first >> second;
    g[first - 1].push_back(second - 1);
    g[second - 1].push_back(first - 1);
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    int first;
    cin >> first;
    a.insert(first - 1);
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    int first;
    cin >> first;
    b.insert(first - 1);
  }
  cout << "B " << *b.begin() + 1 << endl;
  cin >> s;
  s--;
  p[s] = -1;
  q[head++] = s;
  while (head != tail) {
    int v = q[tail++];
    if (a.count(v)) {
      cout << "A " << v + 1 << endl;
      int first;
      cin >> first;
      if (b.count(first - 1)) {
        cout << "C " << v + 1 << endl;
        return;
      } else {
        cout << "C -1" << endl;
        return;
      }
    }
    for (int i = 0; i < g[v].size(); i++) {
      int to = g[v][i];
      if (to == p[v]) continue;
      p[to] = v;
      q[head++] = to;
    }
  }
  cout << "C -1" << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) get_ans();
  return 0;
}
