#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[1005];
long long int a[1005], b[1005], pr[1005], vl;
void dfs(long long int node) {
  if (a[node] > 0) {
    vl = node;
    return;
  }
  if (pr[node] == 1) return;
  pr[node] = 1;
  for (long long int i = 0; i < adj[node].size(); i++) dfs(adj[node][i]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t, n, i, x, y;
  cin >> t;
  while (t--) {
    for (i = 0; i < 1002; i++) {
      pr[i] = a[i] = b[i] = 0;
      adj[i].clear();
    }
    cin >> n;
    for (i = 0; i < n - 1; i++) {
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> x;
      a[x]++;
    }
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> x;
      b[x]++;
    }
    cout << "B " << x << endl;
    fflush(stdout);
    cin >> x;
    dfs(x);
    x = vl;
    cout << "A " << vl << endl;
    fflush(stdout);
    cin >> vl;
    if (b[vl] > 0) {
      cout << "C " << x << endl;
      fflush(stdout);
    } else {
      cout << "C " << -1 << endl;
      fflush(stdout);
    }
  }
  return 0;
}
