#include <bits/stdc++.h>
using namespace std;
struct STUFF {
  int64_t a, b, c, d;
  STUFF(int64_t q = -1, int64_t w = -1, int64_t e = -1, int64_t r = -1)
      : a(q), b(w), c(e), d(r) {}
};
int64_t mod = 1e8, inf = 4e18;
int64_t sum = 0;
int64_t tmp3 = 0, tmp = 0, tmp2 = 0, comb = 1;
vector<int64_t> check, st, st2;
int64_t maxi = 0, mini = inf;
vector<vector<int64_t> > g;
bool high = 0;
int64_t n, m, t;
int64_t logn = 1;
set<int64_t> t1;
void dfs(int64_t cur, vector<int64_t>& last, int64_t fill) {
  check[cur] = 1;
  if (t1.find(cur) != t1.end()) fill = cur;
  last[cur] = fill;
  for (auto v : g[cur]) {
    if (!check[v]) dfs(v, last, fill);
  }
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  cout << fixed << setprecision(0);
  cin >> t;
  for (int64_t k1, k2; t--;) {
    cin >> n;
    g.clear();
    g.resize(n);
    for (int64_t i = 0; i < n - 1; i++) {
      cin >> tmp >> tmp2;
      tmp -= 1, tmp2 -= 1;
      g[tmp].push_back(tmp2);
      g[tmp2].push_back(tmp);
    }
    cin >> k1;
    t1.clear();
    for (int64_t i = 0; i < k1; i++) {
      cin >> tmp;
      t1.insert(tmp - 1);
    }
    cin >> k2;
    set<int64_t> t2;
    for (int64_t i = 0; i < k2; i++) cin >> tmp, t2.insert(tmp - 1);
    vector<int64_t> last(n);
    check.clear(), check.resize(n, 0);
    dfs(*t1.begin(), last, *t1.begin());
    cout << "B " << *t2.begin() + 1 << endl;
    fflush(stdout);
    int64_t val;
    cin >> val;
    val -= 1;
    cout << "A " << last[val] + 1 << endl;
    fflush(stdout);
    int64_t res = last[val] + 1;
    cin >> val;
    val -= 1;
    if (t2.find(val) != t2.end())
      cout << "C " << res << endl;
    else
      cout << "C " << -1 << endl;
    fflush(stdout);
  }
  return 0;
}
