#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1e18;
const int MX = 100001;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int N;
    cin >> N;
    vector<int> edges[N + 1];
    int a, b;
    for (int i = 0; i < N - 1; ++i) {
      cin >> a >> b;
      edges[a].push_back(b);
      edges[b].push_back(a);
    }
    int k;
    cin >> k;
    vector<bool> mano(N + 1, false);
    for (int i = 0; i < k; ++i) {
      cin >> a;
      mano[a] = true;
    }
    cin >> k;
    vector<bool> jo(N + 1, false);
    for (int i = 0; i < k; ++i) {
      cin >> a;
      jo[a] = true;
    }
    cout << "B " << a << endl;
    int ans;
    cin >> ans;
    if (mano[ans]) {
      cout << "C " << ans << endl;
      continue;
    }
    queue<int> q;
    q.push(ans);
    int c;
    vector<bool> buvau(N + 1, false);
    while (!q.empty()) {
      c = q.front();
      q.pop();
      buvau[c] = true;
      if (mano[c]) break;
      for (auto u : edges[c])
        if (!buvau[u]) q.push(u);
    }
    cout << "A " << c << endl;
    cin >> ans;
    if (jo[ans]) {
      cout << "C " << c << endl;
    } else
      cout << "C -1" << endl;
  }
}
