#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
using ll = long long;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 5;
int n;
vector<int> g[maxn];
int ask(char c, int x) {
  cout << c << " " << x << endl;
  int res;
  cin >> res;
  return res;
}
void solve() {
  cin >> n;
  for (int i = 0; i <= n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  set<int> a, b;
  int k1, k2;
  cin >> k1;
  for (int i = 0; i < k1; i++) {
    int x;
    cin >> x;
    a.insert(x);
  }
  cin >> k2;
  for (int i = 0; i < k2; i++) {
    int x;
    cin >> x;
    b.insert(x);
  }
  int val = ask('B', *b.begin());
  vector<int> dist(n + 1, -1);
  dist[val] = 0;
  queue<int> qq;
  qq.push(val);
  while (qq.size()) {
    int at = qq.front();
    qq.pop();
    for (int to : g[at]) {
      if (dist[to] == -1) {
        dist[to] = 1 + dist[at];
        qq.push(to);
      }
    }
  }
  vector<pair<int, int>> v;
  for (int i = 1; i <= n; i++) {
    if (a.count(i)) {
      v.push_back({dist[i], i});
    }
  }
  sort(v.begin(), v.end());
  if ((int)v.size() > 4) {
    v.resize(4);
  }
  for (auto p : v) {
    int node = p.second;
    int val2 = ask('A', node);
    if (b.count(val2)) {
      cout << "C " << node << endl;
      return;
    }
  }
  cout << "C -1" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
