#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long double EPS = 1e-7;
vector<vector<long long> > g;
vector<long long> tin;
long long cl = 0;
void dfs(long long v, long long p) {
  ++cl;
  tin[v] = cl;
  for (long long to : g[v]) {
    if (to != p) {
      dfs(to, v);
    }
  }
}
void solve() {
  long long n;
  cin >> n;
  g.clear();
  g.resize(n);
  tin.clear();
  tin.resize(n);
  for (long long i = 0; i < n - 1; ++i) {
    long long a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  long long k1;
  cin >> k1;
  vector<long long> x(k1);
  set<long long> set_x;
  for (long long& it : x) {
    cin >> it;
    set_x.insert(it);
  }
  long long k2;
  cin >> k2;
  vector<long long> y(k2);
  set<long long> set_y;
  for (long long& it : y) {
    cin >> it;
    set_y.insert(it);
  }
  cout << "B " << y[0] << endl;
  long long x_num;
  cin >> x_num;
  if (set_x.count(x_num)) {
    cout << "C " << x_num << endl;
    return;
  }
  cl = 0;
  dfs(0, -1);
  long long root = x[0];
  for (long long v : x) {
    if (tin[v - 1] < tin[root - 1]) {
      root = v;
    }
  }
  cout << "A " << root << endl;
  long long res;
  cin >> res;
  if (set_y.count(res)) {
    cout << "C " << root << endl;
    return;
  }
  long long closest = x[0];
  for (long long v : x) {
    if ((tin[v - 1] - tin[x_num - 1]) < (tin[closest - 1] - tin[x_num - 1])) {
      closest = v;
    }
  }
  cout << "A " << closest << endl;
  cin >> res;
  if (set_y.count(res)) {
    cout << "C " << closest << endl;
    return;
  }
  cout << "C " << -1 << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  for (long long i = 0; i < t; ++i) {
    solve();
  }
  return 0;
}
