#include <bits/stdc++.h>
using namespace std;
const int mx = 1005;
vector<int> adj[mx];
int n, t, t1, t2, t3, k1, k2;
bool m1[mx], m2[mx];
void dfs(int v, int p = -1) {
  if (m1[v] && t3 == 0) t3 = v;
  for (auto u : adj[v])
    if (u != p) dfs(u, v);
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) adj[i].clear(), m1[i] = 0, m2[i] = 0;
  for (int i = 1; i < n; i++) {
    cin >> t1 >> t2;
    adj[t1].push_back(t2);
    adj[t2].push_back(t1);
  }
  cin >> k1;
  for (int i = 1; i <= k1; i++) {
    cin >> t1;
    m1[t1] = 1;
  }
  cin >> k2;
  for (int i = 1; i <= k2; i++) {
    cin >> t2;
    m2[t2] = 1;
  }
  cout << "B " << t2 << endl;
  cin >> t1;
  if (t1 == -1) exit(0);
  if (m1[t1]) {
    cout << "C " << t1 << endl;
    return;
  }
  t3 = 0;
  dfs(t1);
  cout << "A " << t3 << endl;
  cin >> t1;
  if (t1 == -1) exit(0);
  if (m2[t1]) {
    cout << "C " << t3 << endl;
    return;
  } else {
    cout << "C " << -1 << endl;
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
}
