#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793238463;
vector<vector<int> > g;
int parent[1009];
void dfs(int u, int prev) {
  parent[u] = prev;
  for (int v : g[u])
    if (v != prev) dfs(v, u);
}
bool fme[1009], fhim[1009];
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    g = vector<vector<int> >(n + 9);
    for (int i = 0; i < (n - 1); i++) {
      int u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    int k1;
    cin >> k1;
    vector<int> me(k1);
    memset((fme), (0), sizeof(fme));
    for (int i = 0; i < (k1); i++) cin >> me[i], fme[me[i]] = 1;
    int k2;
    cin >> k2;
    vector<int> him(k2);
    memset((fhim), (0), sizeof(fhim));
    for (int i = 0; i < (k2); i++) cin >> him[i], fhim[him[i]] = 1;
    int root = me[0];
    memset((parent), (0), sizeof(parent));
    dfs(root, -1);
    cout << "B " << him[0] << endl;
    int u;
    cin >> u;
    while (u != -1 && !fme[u]) u = parent[u];
    if (u == -1)
      cout << "C -1" << endl;
    else {
      cout << "A " << u << endl;
      int v;
      cin >> v;
      if (fhim[v])
        cout << "C " << u << endl;
      else
        cout << "C -1" << endl;
    }
  }
  return 0;
}
