#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
void dfs(int v, int pa, vector<int> &dist) {
  for (int u : adj[v])
    if (u != pa) {
      dist[u] = min(dist[u], dist[v] + 1);
      dfs(u, v, dist);
    }
}
void test_case() {
  int a;
  cin >> a;
  adj = vector<vector<int>>(a + 1);
  for (int i = 0; i < a - 1; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int k1;
  cin >> k1;
  vector<int> mine(k1);
  for (int &x : mine) cin >> x;
  int k2;
  cin >> k2;
  vector<int> his(k2);
  for (int &x : his) cin >> x;
  cout << "B " << his[0] << endl;
  int response;
  cin >> response;
  vector<int> dist(a + 1, 1e9);
  dist[response] = 0;
  dfs(response, -1, dist);
  int bst = mine[0];
  for (int x : mine) {
    if (dist[x] < dist[bst]) bst = x;
  }
  cout << "A " << bst << endl;
  int K;
  cin >> K;
  if (find(his.begin(), his.end(), K) != his.end())
    cout << "C " << bst << endl;
  else
    cout << "C -1" << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    test_case();
  }
}
