#include <bits/stdc++.h>
using namespace std;
int n;
set<int> me, lichen;
vector<vector<int> > g;
int bfs(int start) {
  queue<int> q;
  q.push(start);
  vector<int> dist(n + 1, -1);
  dist[start] = 0;
  while (q.size() > 0) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < g[u].size(); ++i) {
      if (dist[g[u][i]] == -1) {
        dist[g[u][i]] = dist[u] + 1;
        q.push(g[u][i]);
      }
    }
  }
  int ans = -1;
  for (int i = 1; i <= n; ++i) {
    if (me.find(i) != me.end()) {
      ans = ans == -1 || dist[ans] > dist[i] ? i : ans;
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int T, sz, ans, node;
  for (cin >> T; T-- > 0;) {
    cin >> n;
    g.assign(n + 1, vector<int>());
    for (int i = 0, u, v; i < n - 1; ++i) {
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    cin >> sz;
    me.clear();
    for (int i = 0, v; i < sz; ++i) {
      cin >> v;
      me.insert(v);
    }
    cin >> sz;
    lichen.clear();
    for (int i = 0, v; i < sz; ++i) {
      cin >> v;
      lichen.insert(v);
    }
    cout << "B " << *lichen.begin() << endl;
    cout.flush();
    cin >> ans;
    node = bfs(ans);
    cout << "A " << node << endl;
    cout.flush();
    cin >> ans;
    cout << "C " << (lichen.find(ans) == lichen.end() ? -1 : node) << endl;
    cout.flush();
  }
}
