#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
using namespace std;
const int N = 1e3 + 5;
int t, n, u, v, k1, k2, now = -1;
bool vis[N], vis1[N], vis2[N];
vector<int> g[N];
void init(int n) {
  for (int i = 1; i <= n; ++i) vis[i] = vis1[i] = vis2[i] = false, g[i].clear();
}
void dfs(int u) {
  vis[u] = true;
  if (vis1[u] && now == -1) now = u;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (!vis[v]) dfs(v);
  }
}
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    init(n);
    for (int i = 1; i < n; ++i) {
      scanf("%d %d", &u, &v);
      g[u].push_back(v);
      g[v].push_back(u);
    }
    scanf("%d", &k1);
    while (k1--) scanf("%d", &u), vis1[u] = 1;
    scanf("%d", &k2);
    while (k2--) scanf("%d", &u), vis2[u] = 1;
    cout << "B " << u << endl;
    cin >> u;
    now = -1;
    dfs(u);
    cout << "A " << now << endl;
    cin >> u;
    if (vis2[u])
      cout << "C " << now << endl;
    else
      cout << "C -1" << endl;
  }
  return 0;
}
