#include <bits/stdc++.h>
using namespace std;
vector<int> g[1010];
int a[1010], b[1010], vis[1010];
set<int> aa, bb;
int bfs(int x) {
  memset(vis, 0, sizeof vis);
  queue<int> q;
  q.push(x);
  vis[x] = 1;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (aa.count(v) > 0) return v;
    for (auto it : g[v]) {
      if (!vis[it]) {
        vis[it] = 1;
        q.push(it);
      }
    }
  }
  return -1;
}
int main() {
  int t, n, x, y, k, kk;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i <= n; i++) g[i].clear();
    aa.clear();
    bb.clear();
    for (int i = 1; i < n; i++) {
      cin >> x >> y;
      g[x].push_back(y);
      g[y].push_back(x);
    }
    cin >> k;
    for (int i = 0; i < k; i++) {
      cin >> a[i];
      aa.insert(a[i]);
    }
    cin >> kk;
    for (int i = 0; i < kk; i++) {
      cin >> b[i];
      bb.insert(b[i]);
    }
    cout << "B " << b[0] << endl;
    fflush(stdout);
    cin >> x;
    int v = bfs(x);
    cout << "A " << v << endl;
    fflush(stdout);
    cin >> x;
    if (bb.count(x) > 0) {
      cout << "C " << v << endl;
      fflush(stdout);
    } else {
      cout << "C -1" << endl;
      fflush(stdout);
    }
  }
  return 0;
}
