#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
float inf = std::numeric_limits<double>::infinity();
long long int INF = std::numeric_limits<long long int>::max();
const int N = 1005;
set<int> X, Y;
vector<int> G[N];
int dfs(int x, int pre) {
  if (X.count(x)) return x;
  int ret;
  for (auto v : G[x]) {
    if (v == pre) continue;
    ret = dfs(v, x);
    if (ret) return ret;
  }
  return 0;
}
int main() {
  int t;
  cin >> t;
  ;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) G[i].clear();
    X.clear(), Y.clear();
    int a, b;
    for (int i = 1; i < n; i++) {
      cin >> a >> b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    int k1, k2, v;
    cin >> k1;
    for (int i = 0; i < k1; i++) cin >> v, X.insert(v);
    cin >> k2;
    for (int i = 0; i < k2; i++) cin >> v, Y.insert(v);
    cout << "B " << *(Y.begin()) << endl;
    cout.flush();
    int x1, x2, y2;
    cin >> x1;
    x2 = dfs(x1, 0);
    cout << "A " << x2 << endl;
    cout.flush();
    cin >> y2;
    if (Y.count(y2))
      cout << "C " << x2 << endl;
    else
      cout << "-1" << endl;
    cout.flush();
  }
  return 0;
}
