#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int test, n, k1, k2;
vector<int> e[N];
set<int> ms1, ms2;
queue<int> qu;
bool check[N];
int bfs(int s) {
  while (qu.size()) qu.pop();
  for (int i = 1; i <= n; ++i) {
    check[i] = false;
  }
  qu.push(s);
  check[s] = true;
  while (qu.size()) {
    int u = qu.front();
    qu.pop();
    if (ms1.find(u) != ms1.end()) return u;
    for (int v : e[u]) {
      if (!check[v]) {
        qu.push(v);
        check[v] = true;
      }
    }
  }
  return -1;
}
void solve() {
  cin >> n;
  ms1.clear();
  ms2.clear();
  for (int i = 1; i <= n; ++i) {
    e[i].clear();
  }
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  cin >> k1;
  for (int i = 1; i <= k1; ++i) {
    int x;
    cin >> x;
    ms1.insert(x);
  }
  cin >> k2;
  for (int i = 1; i <= k2; ++i) {
    int x;
    cin >> x;
    ms2.insert(x);
  }
  int u, ans;
  u = *ms2.begin();
  cout << "B " << u << "\n";
  fflush(stdout);
  cin >> ans;
  u = bfs(ans);
  cout << "A " << u << "\n";
  fflush(stdout);
  cin >> ans;
  if (ms2.find(ans) != ms2.end()) {
    cout << "C " << u << "\n";
    fflush(stdout);
    return;
  }
  cout << "C -1\n";
  fflush(stdout);
  return;
}
int main() {
  cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}
