#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100;
vector<int> g[maxn];
bool mine[maxn];
bool his[maxn];
bool used[maxn];
int dfs(int v, int pv = -1) {
  if (used[v]) return -1;
  used[v] = 1;
  if (mine[v]) return v;
  for (int u : g[v])
    if (u != pv) {
      int d = dfs(u, v);
      if (d != -1) return d;
    }
  return -1;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < maxn; ++i) {
      g[i].clear();
      mine[i] = 0;
      his[i] = 0;
      used[i] = 0;
    }
    for (int i = 1; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    int k, x;
    cin >> k;
    for (int i = 0; i < k; ++i) {
      cin >> x;
      mine[x] = 1;
    }
    cin >> k;
    for (int i = 0; i < k; ++i) {
      cin >> x;
      his[x] = 1;
    }
    cout << "B " << x << endl;
    cin >> x;
    if (mine[x]) {
      cout << "C " << x << endl;
      continue;
    }
    int ft = dfs(x);
    cout << "A " << ft << endl;
    cin >> x;
    cout << "C ";
    if (his[x]) {
      cout << ft << endl;
    } else
      cout << -1 << endl;
  }
}
