#include <bits/stdc++.h>
using namespace std;
vector<int> g[1002];
bool vis[1002];
bool my[1002], chen[1002];
int dfs(int n) {
  if (my[n] == 1) return n;
  vis[n] = 1;
  for (int i = 0; i < g[n].size(); i++) {
    int v = g[n][i];
    if (!vis[v]) {
      int ans = dfs(v);
      if (ans != -1) return ans;
    }
  }
  return -1;
}
void make() {
  memset((vis), 0, sizeof(vis));
  memset((my), 0, sizeof(my));
  memset((chen), 0, sizeof(chen));
  for (int i = 0; i < 1002; i++) g[i].clear();
}
int main() {
  int t, i, j;
  cin >> t;
  while (t--) {
    make();
    int n, k1, k2;
    cin >> n;
    for (i = 0; i < n - 1; i++) {
      int u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    cin >> k1;
    for (i = 0; i < k1; i++) {
      int u;
      cin >> u;
      my[u] = 1;
    }
    cin >> k2;
    for (i = 0; i < k2; i++) {
      int u;
      cin >> u;
      chen[u] = 1;
    }
    int q;
    for (i = 1; i <= n; i++)
      if (chen[i] == 1) break;
    cout << "B " << i << endl;
    cout.flush();
    cin >> q;
    if (my[q] == 1) {
      cout << "C " << q << endl;
      cout.flush();
      continue;
    }
    int ans = dfs(q);
    cout << "A " << ans << endl;
    cout.flush();
    cin >> q;
    if (chen[q] == 1) {
      cout << "C " << ans << endl;
      cout.flush();
    } else {
      cout << "C " << -1 << endl;
      cout.flush();
    }
  }
}
