#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<int> > tree(n);
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      tree[a].push_back(b);
      tree[b].push_back(a);
    }
    vector<bool> subtree1(n, false);
    vector<bool> subtree2(n, false);
    int k1;
    cin >> k1;
    for (int i = 0; i < k1; i++) {
      int a;
      cin >> a;
      a--;
      subtree1[a] = true;
    }
    int k2, node;
    cin >> k2;
    for (int i = 0; i < k2; i++) {
      cin >> node;
      node--;
      subtree2[node] = true;
    }
    cout << "B " << node + 1 << endl;
    int resp;
    cin >> resp;
    resp--;
    vector<int> dist(n, INT_MAX);
    queue<int> q;
    q.push(resp);
    dist[resp] = 0;
    int nearest;
    while (!q.empty()) {
      int a = q.front();
      q.pop();
      if (subtree1[a]) {
        nearest = a;
        break;
      }
      for (int v : tree[a]) {
        if (dist[a] + 1 < dist[v]) {
          dist[v] = dist[a] + 1;
          q.push(v);
        }
      }
    }
    cout << "A " << nearest + 1 << endl;
    cin >> resp;
    resp--;
    if (subtree2[resp])
      cout << "C " << nearest + 1 << endl;
    else
      cout << "C -1" << endl;
  }
  return 0;
}
