#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a[n];
    for (long long i = (0); i < (n - 1); i++) {
      long long x, y;
      cin >> x >> y;
      x--;
      y--;
      a[x].push_back(y);
      a[y].push_back(x);
    }
    long long k1, k2;
    cin >> k1;
    long long x[k1];
    for (long long i = (0); i < (k1); i++) {
      cin >> x[i];
      x[i]--;
    }
    cin >> k2;
    long long y[k2];
    for (long long i = (0); i < (k2); i++) {
      cin >> y[i];
      y[i]--;
    }
    set<long long> s;
    for (long long i = (0); i < (k2); i++) s.insert(y[i]);
    cout << "B " << y[0] + 1 << "\n";
    cout.flush();
    long long r, y1;
    cin >> r;
    r--;
    long long dist[n];
    for (long long i = (0); i < (n); i++) dist[i] = 0;
    long long visited[n];
    for (long long i = (0); i < (n); i++) visited[i] = 0;
    queue<long long> q;
    q.push(r);
    dist[r] = 0;
    visited[r] = 1;
    while (q.size() != 0) {
      long long c = q.front();
      q.pop();
      visited[c] = 1;
      for (long long z : a[c]) {
        if (!visited[z]) {
          visited[z] = 1;
          q.push(z);
          dist[z] = dist[c] + 1;
        }
      }
    }
    long long index = -1;
    long long ans = 1e10;
    for (long long i = (0); i < (k1); i++) {
      if (dist[x[i]] < ans) {
        ans = dist[x[i]];
        index = x[i];
      }
    }
    if (index == -1) {
      cout << "C -1"
           << "\n";
      cout.flush();
      continue;
    }
    cout << "A " << index + 1 << "\n";
    cout.flush();
    cin >> y1;
    y1--;
    if (s.find(y1) != s.end()) {
      cout << "C " << index + 1 << "\n";
      cout.flush();
      continue;
    }
    cout << "C -1"
         << "\n";
    cout.flush();
  }
}
