#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,mmx,popcnt")
using namespace std;
const int INF = 1e9 + 7;
vector<vector<int>> gr;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    gr.clear();
    gr.resize(n + 1);
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      cin >> a >> b;
      gr[a].push_back(b);
      gr[b].push_back(a);
    }
    unordered_map<int, bool> ma1, ma2;
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
      int a;
      cin >> a;
      ma1[a] = true;
    }
    cin >> k;
    for (int i = 0; i < k; ++i) {
      int a;
      cin >> a;
      ma2[a] = true;
    }
    cout << "B " << ma2.begin()->first << endl;
    int q;
    cin >> q;
    queue<int> que;
    que.push(q);
    vector<bool> used(n + 1, false);
    while (!que.empty()) {
      int now = que.front();
      que.pop();
      if (ma1[now]) {
        cout << "A " << now << endl;
        cin >> q;
        if (ma2[q]) {
          cout << "C " << now << endl;
        } else {
          cout << "C -1" << endl;
        }
        break;
      }
      for (auto c : gr[now])
        if (!used[c]) {
          que.push(c);
          used[c] = true;
        }
    }
  }
  return 0;
}
