#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
set<long long int> x;
long long int mindist, node;
bool marked[1500];
void dfs(vector<long long int> *g, long long int a, long long int dist) {
  if (marked[a] == true) return;
  marked[a] = true;
  if (x.find(a) != x.end()) {
    if (mindist > dist) {
      node = a;
      mindist = dist;
    }
  }
  for (auto it : g[a]) {
    dfs(g, it, dist + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin.tie(NULL);
  long long int t, n, i, j, k;
  cin >> t;
  while (t--) {
    vector<long long int> g[1500], y;
    cin >> n;
    long long int a, b, k1, k2;
    for (i = 0; i < n - 1; i++) {
      cin >> a >> b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    cin >> k1;
    x.clear();
    for (i = 0; i < k1; i++) {
      cin >> a;
      x.insert(a);
    }
    cin >> k2;
    for (i = 0; i < k2; i++) {
      cin >> a;
      y.push_back(a);
    }
    cout << "B " << y[0] << "\n";
    cout.flush();
    cin >> a;
    mindist = 1e10;
    for (i = 0; i <= n; i++) marked[i] = false;
    dfs(g, a, 1);
    cout << "A " << node << "\n";
    cout.flush();
    cin >> b;
    int s, flag = 0;
    for (i = 0; i < k2; i++)
      if (b == y[i]) flag = 1;
    if (flag)
      cout << "C " << node << "\n";
    else
      cout << "C " << -1 << "\n";
    cout.flush();
  }
  return 0;
}
