#include <bits/stdc++.h>
#pragma comment(linker, "/stack:16777216")
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000;
const long long LINF = INF * (long long)INF;
const int MAX = 2007;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int MOD = 998244353;
vector<int> G[MAX];
bool C[MAX];
int p[MAX];
void dfs(int v, int par) {
  p[v] = par;
  for (int i = (0); i < ((int)G[v].size()); ++i) {
    int to = G[v][i];
    if (to == par) continue;
    dfs(to, v);
  }
}
int main() {
  int t;
  cin >> t;
  for (int tt = (0); tt < (t); ++tt) {
    int n;
    cin >> n;
    for (int i = (0); i < (n); ++i) {
      G[i].clear();
    }
    for (int i = (0); i < (n - 1); ++i) {
      int a, b;
      scanf("%d%d", &a, &b);
      --a;
      --b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    memset(C, 0, sizeof(C));
    int k1;
    cin >> k1;
    vector<int> A(k1);
    for (int i = (0); i < (k1); ++i) {
      scanf("%d", &A[i]);
      --A[i];
      C[A[i]] = 1;
    }
    int k2;
    cin >> k2;
    vector<int> B(k2);
    for (int i = (0); i < (k2); ++i) {
      scanf("%d", &B[i]);
      --B[i];
    }
    int root = A[0];
    dfs(root, -1);
    cout << "A " << root + 1 << endl;
    int v;
    cin >> v;
    --v;
    bool ok = false;
    for (int i = (0); i < ((int)B.size()); ++i) {
      if (B[i] == v) {
        ok = true;
        break;
      }
    }
    if (ok) {
      cout << "C " << root + 1 << endl;
      continue;
    }
    cout << "B " << B[0] + 1 << endl;
    cin >> v;
    --v;
    while (!C[v]) {
      v = p[v];
    }
    cout << "A " << v + 1 << endl;
    int u;
    cin >> u;
    --u;
    ok = false;
    for (int i = (0); i < ((int)B.size()); ++i) {
      if (B[i] == u) {
        ok = true;
        break;
      }
    }
    if (ok) {
      cout << "C " << v + 1 << endl;
      continue;
    }
    cout << "C " << -1 << endl;
  }
  return 0;
}
