#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
vector<int> G[N];
int Select[2][N];
int K[2];
bool vis[N];
int Tag[N];
set<int> myset;
int dfs(int u) {
  if (Tag[u] == 1) return u;
  vis[u] = true;
  for (int i = 0; i < ((int)G[u].size()); i++) {
    int v = G[u][i];
    if (!vis[v]) {
      int ret = dfs(v);
      if (ret) return ret;
    }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    memset(vis, false, sizeof(vis));
    memset(Tag, 0, sizeof(Tag));
    myset.clear();
    int n, u, v;
    cin >> n;
    for (int i = 1; i < n + 1; i++) G[i].clear();
    for (int i = 0; i < n - 1; i++)
      cin >> u >> v, G[u].push_back(v), G[v].push_back(u);
    int k1, k2;
    cin >> K[0];
    for (int i = 0; i < K[0]; i++) {
      cin >> Select[0][i];
      Tag[Select[0][i]] = 1;
    }
    cin >> K[1];
    for (int i = 0; i < K[1]; i++) {
      cin >> Select[1][i];
      myset.insert(Select[1][i]);
    }
    cout << "B " << Select[1][0] << endl;
    ;
    int res = 0;
    cin >> res;
    bool ok = (Tag[res] == 1);
    if (!ok) {
      int qnode = dfs(res);
      cout << "A " << qnode << endl;
      cin >> res;
      if (myset.find(res) != myset.end())
        ok = true;
      else
        ok = false;
      cout << "C ";
      if (ok)
        cout << qnode << endl;
      else
        cout << -1 << endl;
    } else {
      cout << "C " << res << endl;
    }
  }
  return 0;
}
