#include <bits/stdc++.h>
using namespace std;
int GLL(long long& x) { return scanf("%lld", &x); }
int GI(int& x) { return scanf("%d", &x); }
int t, n, k1, k2, ans;
vector<vector<int>> adj;
const int A = 0;
const int B = 1;
void queryA(int u) {
  cout << "A " << u << endl;
  cin >> ans;
}
void queryB(int u) {
  cout << "B " << u << endl;
  cin >> ans;
}
void answer(int u) { cout << "C " << u << endl; }
vector<int> xpath;
bool dfs(int u, int p, int tgt) {
  xpath.push_back(u);
  if (u == tgt) {
    return true;
  }
  for (auto v : adj[u]) {
    if (v != p) {
      if (dfs(v, u, tgt)) {
        return true;
      }
    }
  }
  xpath.pop_back();
  return false;
}
void solve() {
  GI(n);
  adj = vector<vector<int>>();
  adj.resize(n + 1);
  for (int i = 0; i < (int)(n - 1); i++) {
    int a, b;
    GI(a);
    GI(b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  GI(k1);
  set<int> x;
  for (int i = 0; i < (int)(k1); i++) {
    int xi;
    GI(xi);
    x.insert(xi);
  }
  GI(k2);
  set<int> y;
  for (int i = 0; i < (int)(k2); i++) {
    int yi;
    GI(yi);
    y.insert(yi);
  }
  queryB(*y.begin());
  xpath.clear();
  dfs(*x.begin(), *x.begin(), ans);
  int fx = -1;
  for (auto u : xpath) {
    if (x.count(u)) {
      fx = u;
    }
  }
  queryA(fx);
  if (y.count(ans)) {
    answer(fx);
  } else {
    answer(-1);
  }
}
int main() {
  GI(t);
  while (t--) {
    solve();
  }
  return 0;
}
