#include <bits/stdc++.h>
using namespace std;
const int N = 2000010, mod = 1e9 + 7;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
vector<int> g[N];
int vis1[N], vis2[N], get, d[N], p[N];
void dfs(int u, int pre, int dep) {
  d[u] = dep;
  for (auto e : g[u]) {
    if (e == pre) continue;
    dfs(e, u, dep + 1);
  }
}
void solve() {
  int n = read();
  for (int i = 1; i <= n; ++i) g[i].clear(), vis1[i] = vis2[i] = 0;
  for (int i = 1; i < n; ++i) {
    int x = read(), y = read();
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int k1 = read();
  for (int i = 1; i <= k1; ++i) {
    p[i] = read();
    vis1[p[i]] = 1;
  }
  int k2 = read();
  int p2;
  for (int i = 1; i <= k2; ++i) {
    int x = read();
    vis2[x] = 1;
    p2 = x;
  }
  cout << 'B' << ' ' << p2 << endl;
  int p1 = read();
  dfs(p1, 0, 0);
  int dep = 1e8, ans;
  for (int i = 1; i <= k1; ++i) {
    if (d[p[i]] < dep) dep = d[p[i]], ans = p[i];
  }
  cout << 'A' << ' ' << ans << endl;
  int get = read();
  if (vis2[get])
    cout << "C " << get << endl;
  else
    cout << "C " << -1 << endl;
}
int main() {
  int T = read();
  while (T--) {
    solve();
  }
  return 0;
}
