#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int MAXN = (int)1000 + 5;
int t, n, k1, k2;
vector<int> e[MAXN];
set<int> my, li;
int dfs(int u, int p) {
  if (my.count(u)) return u;
  for (int v : e[u])
    if (v != p) {
      int res = dfs(v, u);
      if (res != 0) return res;
    }
  return 0;
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; ++i) e[i].clear();
    my.clear();
    li.clear();
    int a, b;
    for (int i = 0; i < n - 1; ++i) {
      cin >> a >> b;
      e[a].push_back(b);
      e[b].push_back(a);
    }
    cin >> k1;
    for (int i = 0; i < k1; ++i) {
      cin >> a;
      my.insert(a);
    }
    cin >> k2;
    for (int i = 0; i < k2; ++i) {
      cin >> a;
      li.insert(a);
    }
    cout << "B " << *li.begin() << endl;
    fflush(stdout);
    cin >> a;
    assert(a != -1);
    if (my.count(a)) {
      cout << "C " << a << endl;
      fflush(stdout);
      continue;
    }
    int q = dfs(a, 0);
    cout << "A " << q << endl;
    fflush(stdout);
    cin >> a;
    assert(a != -1);
    if (li.count(a)) {
      cout << "C " << q << endl;
      fflush(stdout);
      continue;
    } else {
      cout << "C " << -1 << endl;
      fflush(stdout);
      continue;
    }
  }
  return 0;
}
