#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T& x) {
  cin >> x;
}
template <class H, class... T>
void read(H& h, T&... t) {
  read(h);
  read(t...);
}
template <class A>
void read(A* x, int size) {
  for (int i = (0); (1) > 0 ? i < (size) : i > (size); i += (1)) read(x[i]);
}
template <class A>
void read(vector<A>& x) {
  for (auto& a : x) read(a);
}
template <class T>
void print(T& x) {
  cout << x << ' ';
}
template <class H, class... T>
void print(H h, T... t) {
  print(h);
  print(t...);
}
template <class A>
void print(A* x, int size) {
  for (int i = (0); (1) > 0 ? i < (size) : i > (size); i += (1)) print(x[i]);
  cout << '\n';
}
template <class A>
void print(vector<A>& x) {
  for (auto& a : x) print(a);
}
template <class H, class... T>
void debug(H h, T... t) {
  print(h, t...);
  cout << endl;
}
const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1},
          d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int N = 1010, mod = 1e9 + 7;
vector<vector<int>> g;
int n;
unordered_set<int> st1, st2;
int dfs(int s, int p, int u) {
  if (s == u) return s;
  int ans = -1;
  for (int v : g[s]) {
    if (v != p) {
      int x = dfs(v, s, u);
      if (x == -1) continue;
      ans = x;
    }
  }
  if (ans == -1) return -1;
  if (st1.find(ans) != st1.end()) return ans;
  return s;
}
void solve() {
  read(n);
  int u, v, k1, k2;
  g.clear();
  st1.clear();
  st2.clear();
  g.resize(n + 1);
  for (int i = (0); (1) > 0 ? i < (n - 1) : i > (n - 1); i += (1)) {
    read(u, v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  read(k1);
  for (int i = (0); (1) > 0 ? i < (k1) : i > (k1); i += (1)) {
    read(u);
    st1.insert(u);
  }
  read(k2);
  for (int i = (0); (1) > 0 ? i < (k2) : i > (k2); i += (1)) {
    read(u);
    st2.insert(u);
  }
  cout << "A " << (*st1.begin()) << endl;
  cin >> u;
  if (st2.find(u) != st2.end()) {
    cout << "C " << (*st1.begin()) << endl;
    return;
  }
  cout << "B " << (*st2.begin()) << endl;
  cin >> u;
  if (st1.find(u) != st1.end()) {
    cout << "C " << u << endl;
    return;
  }
  u = dfs(*(st1.begin()), 0, u);
  cout << "A " << u << endl;
  cin >> u;
  if (st2.find(u) != st2.end())
    cout << "C " << u << endl;
  else
    cout << "C " << -1 << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int _t;
  cin >> _t;
  while (_t--) solve();
}
