#include <bits/stdc++.h>
using namespace std;
int f1[1010];
int f2[1010];
int used[1010];
queue<int> q;
vector<int> gr[1010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
      int a, b;
      cin >> a >> b;
      gr[a].push_back(b);
      gr[b].push_back(a);
    }
    int k1, k2;
    cin >> k1;
    int nr;
    for (int i = 1; i <= k1; i++) {
      cin >> nr;
      f1[nr] = 1;
    }
    cin >> k2;
    for (int i = 1; i <= k2; i++) {
      cin >> nr;
      f2[nr] = 1;
    }
    cout << "B " << nr << endl;
    cin >> nr;
    used[nr] = 1;
    q.push(nr);
    int ok = 0;
    while (!q.empty()) {
      int now = q.front();
      q.pop();
      if (f1[now]) {
        cout << "A " << now << endl;
        cin >> nr;
        if (f2[nr]) {
          ok = now;
        }
        break;
      }
      for (auto &x : gr[now]) {
        if (!used[x]) {
          used[x] = 1;
          q.push(x);
        }
      }
    }
    if (!ok) {
      cout << "C -1" << endl;
    } else {
      cout << "C " << ok << endl;
    }
    for (int i = 1; i <= n; i++) {
      gr[i].clear();
      used[i] = 0;
      f1[i] = 0;
      f2[i] = 0;
    }
    while (!q.empty()) {
      q.pop();
    }
  }
  return 0;
}
