#include <bits/stdc++.h>
using namespace std;
vector<long long> graf[1005];
bool visited[1005];
bool moje[1005], njegovo[1005];
long long s1[1005], s2[1005], n;
long long aska(long long x) {
  cout << "A " << x << endl;
  long long ret;
  cin >> ret;
  return ret;
}
long long askb(long long y) {
  cout << "B " << y << endl;
  long long ret;
  cin >> ret;
  return ret;
}
void resi(long long ans) { cout << "C " << ans << endl; }
long long bfs(long long x) {
  queue<long long> q;
  for (long i = 1; i <= n; i++) {
    visited[i] = 0;
  }
  q.push(x);
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    if (visited[u]) {
      continue;
    }
    visited[u] = 1;
    if (moje[u]) {
      return u;
    }
    for (auto f : graf[u]) {
      if (!visited[f]) {
        q.push(f);
      }
    }
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long t, a, b, k1, k2;
  cin >> t;
  while (t--) {
    cin >> n;
    for (long i = 1; i <= n; i++) {
      graf[i].clear();
      moje[i] = njegovo[i] = 0;
    }
    for (long i = 1; i < n; i++) {
      cin >> a >> b;
      graf[a].push_back(b);
      graf[b].push_back(a);
    }
    cin >> k1;
    for (long i = 1; i <= k1; i++) {
      cin >> s1[i];
      moje[s1[i]] = 1;
    }
    cin >> k2;
    for (long i = 1; i <= k2; i++) {
      cin >> s2[i];
      njegovo[s2[i]] = 1;
    }
    long long prvi = askb(s2[1]);
    long long drugi = bfs(prvi);
    long long treci = aska(drugi);
    if (njegovo[treci]) {
      resi(drugi);
    } else {
      resi(-1);
    }
  }
}
