#include <bits/stdc++.h>
const int MAXINT = 2147483640;
const long long MAXLL = 9223372036854775800LL;
const long long MAXN = 1000000;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
using namespace std;
long long bp(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans *= a;
    a *= a;
    n >>= 1;
  }
  return ans;
}
vector<long long> v[MAXN];
long long f1[MAXN], f2[MAXN];
long long ans;
void dfs(long long x, long long pred) {
  if (ans != -1) return;
  if (f1[x]) {
    cout << "A " << x << endl;
    long long p;
    cin >> p;
    if (f2[p]) ans = x;
    return;
  }
  for (auto i : v[x])
    if (i != pred) dfs(i, x);
}
int main() {
  long long t;
  cin >> t;
  for (int kol = 1; kol <= t; ++kol) {
    long long n;
    cin >> n;
    for (int j = 1; j <= n; ++j) v[j].clear(), f1[j] = f2[j] = 0;
    for (int j = 1; j < n; ++j) {
      long long x, y;
      cin >> x >> y;
      v[x].push_back(y);
      v[y].push_back(x);
    }
    long long k1, k2;
    cin >> k1;
    for (int j = 1; j <= k1; ++j) {
      long long now;
      cin >> now;
      f1[now] = 1;
    }
    cin >> k2;
    for (int j = 1; j <= k2; ++j) {
      long long now;
      cin >> now;
      f2[now] = 1;
    }
    for (int j = 1; j <= n; ++j)
      if (f2[j]) {
        cout << "B " << j << endl;
        long long x;
        cin >> x;
        if (f1[x]) {
          cout << "C " << x << endl;
        } else {
          ans = -1;
          dfs(x, 0);
          cout << "C " << ans << endl;
        }
        break;
      }
  }
  exit(0);
}
