#include <bits/stdc++.h>
using namespace std;
const int maxn = 1007;
const int inf = INT_MAX;
const long long inff = 1e18;
const long long mod = 1e9 + 7;
int t;
int n;
vector<int> G[maxn];
vector<int> a, b;
int ret, nnow = 0;
int dfs(int now, int p) {
  if (now == ret) return 1;
  int rr = 0;
  for (int i : G[now]) {
    if (i != p) {
      rr = max(rr, dfs(i, now));
    }
  }
  if (rr == 1 && lower_bound((a).begin(), (a).end(), now) != a.end() &&
      (*lower_bound((a).begin(), (a).end(), now)) == now && nnow == 0) {
    nnow = now;
  }
  return rr;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= 1000; i++) G[i].clear();
    a.clear();
    b.clear();
    nnow = 0;
    ret = 0;
    for (int i = 1; i <= n - 1; i++) {
      int x, y;
      cin >> x >> y;
      G[x].push_back(y);
      G[y].push_back(x);
    }
    int x;
    int A, B;
    cin >> A;
    while (A--) {
      cin >> x;
      a.push_back(x);
    }
    sort((a).begin(), (a).end());
    cin >> B;
    while (B--) {
      cin >> x;
      b.push_back(x);
    }
    sort((b).begin(), (b).end());
    cout << "B " << b[0] << endl;
    cout << flush;
    cin >> ret;
    if (lower_bound((a).begin(), (a).end(), ret) != a.end() &&
        (*lower_bound((a).begin(), (a).end(), ret)) == ret) {
      cout << "C " << ret << endl;
      cout << flush;
    } else {
      dfs(a[0], -1);
      cout << "A " << nnow << endl;
      cout << flush;
      cin >> ret;
      if (lower_bound((b).begin(), (b).end(), ret) != b.end() &&
          (*lower_bound((b).begin(), (b).end(), ret)) == ret) {
        cout << "C " << nnow << endl;
        cout << flush;
      } else {
        cout << "C " << -1 << endl;
        cout << flush;
      }
    }
  }
}
