#include <bits/stdc++.h>
using namespace std;
int t, n;
vector<int> graph[1005];
bool st1[1005], st2[1005];
bool visited[1005];
bool finished;
void dfs(int node) {
  if (st1[node]) {
    cout << "A " << node << "\n";
    int node1;
    cin >> node1;
    cout << "C ";
    if (st2[node1]) {
      cout << node << "\n";
    } else {
      cout << -1 << "\n";
    }
    finished = true;
    cout.flush();
    return;
  }
  visited[node] = true;
  for (auto c : graph[node]) {
    if (!visited[c]) {
      dfs(c);
      if (finished) {
        return;
      }
    }
  }
}
int main() {
  cin >> t;
  while (t--) {
    for (int i = 1; i <= n; ++i) {
      graph[i].clear();
      st1[i] = false;
      st2[i] = false;
      visited[i] = false;
      finished = false;
    }
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
      int u, v;
      cin >> u >> v;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    int k1;
    cin >> k1;
    for (int i = 0; i < k1; ++i) {
      int x;
      cin >> x;
      st1[x] = true;
    }
    int k2;
    cin >> k2;
    int s;
    for (int i = 0; i < k2; ++i) {
      int x;
      cin >> x;
      st2[x] = true;
      if (i == 0) {
        s = x;
      }
    }
    cout << "B " << s << "\n";
    cin >> s;
    dfs(s);
  }
  return 0;
}
