#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vll = vector<ll>;
using vs = vector<string>;
constexpr int N = 1005;
vi g[N];
bool mine[N], seen[N];
void work() {
  int n;
  scanf("%d", &n);
  for (auto i = (0); i < (n - 1); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b), g[b].push_back(a);
  }
  int k;
  scanf("%d", &k);
  for (auto i = (0); i < (k); i++) {
    int x;
    scanf("%d", &x);
    mine[x] = true;
  }
  int m;
  scanf("%d", &m);
  vi other;
  for (auto i = (0); i < (m); i++) {
    int x;
    scanf("%d", &x);
    other.push_back(x);
  }
  int start;
  printf("B %d\n", other[0]);
  fflush(stdout);
  scanf("%d", &start);
  int closest = -1;
  deque<int> q;
  if (mine[start]) {
    closest = start;
  } else {
    q.push_back(start);
    seen[start] = true;
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop_front();
    for (auto v : g[u])
      if (!seen[v]) {
        if (mine[v]) {
          closest = v;
          break;
        }
        seen[v] = true;
        q.push_back(v);
      }
    if (closest != -1) break;
  }
  printf("A %d\n", closest);
  fflush(stdout);
  int closest_other;
  scanf("%d", &closest_other);
  bool found = find(begin(other), end(other), closest_other) != other.end();
  printf("C %d\n", found ? closest : -1);
  fflush(stdout);
  for (auto i = (1); i < (n + 1); i++) {
    g[i].clear();
    mine[i] = false;
    seen[i] = false;
  }
}
int main() {
  int t;
  scanf("%d", &t);
  for (auto _ = (0); _ < (t); _++) work();
  return 0;
}
