#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e14;
const long long mod = 1e9 + 7;
long long n, k1, k2;
vector<vector<long long> > adj;
set<long long> x, y;
long long dfs(long long v, long long p) {
  if (x.count(v + 1)) return v;
  for (auto u : adj[v]) {
    if (u == p) continue;
    long long ret = dfs(u, v);
    if (ret >= 0) return ret;
  }
  return -1;
}
void solve() {
  cin >> n;
  adj.assign(n, vector<long long>());
  for (long long i = (0); i < (n - 1); i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  x.clear();
  y.clear();
  cin >> k1;
  for (long long i = (0); i < (k1); i++) {
    long long xi;
    cin >> xi;
    x.insert(xi);
  }
  cin >> k2;
  for (long long i = (0); i < (k2); i++) {
    long long yi;
    cin >> yi;
    y.insert(yi);
  }
  cout << "B " << *y.begin() << endl;
  long long s;
  cin >> s;
  s--;
  long long v = dfs(s, -1);
  cout << "A " << v + 1 << endl;
  cin >> s;
  if (y.count(s)) {
    cout << "C " << v + 1 << endl;
  } else {
    cout << "C " << -1 << endl;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
