#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define ll long long
#define int ll
#define ld long double
//#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC

using namespace std;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int M = 1e9 + 7;
const int N = 2e3 + 7;

int n, x, y, a, b, t;
vector<int> g[N];
vector<bool> A, B, us;

int bfs(int v){
    us.assign(n + 1, 0);
    us[v] = 1;
    queue<int> q;
    q.push(v);
    while (!q.empty()){
        int x = q.front();
        q.pop();
        if (A[x]) return x;
        for (auto to : g[v])
            if (!us[to]) q.push(to), us[to] = 1;
    }
}

void solve(){
    cin >> n;
    A.assign(n + 1, 0);
    B.assign(n + 1, 0);
    for (int i = 0; i < n; i++)
        g[i].clear();
    for (int i = 0; i < n - 1; i++){
        cin >> x >> y;x--;y--;
        g[x].pb(y);
        g[y].pb(x);
    }
    cin >> a;
    for (int i = 0; i < a; i++)
        cin >> x, A[x] = 1;
    cin >> b;
    for (int i = 0; i < b; i++)
        cin >> x, B[x] = 1;
    cout << "B " << x << endl;
    cin >> x;
    int v = bfs(x);
    cout << "A " << v << endl;
    cin >> x;
    if (B[x]) cout << "C " << v << endl;
    else cout << -1 << endl;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif
    cin >> t;
    while (t--){
        solve();
    }
    return 0;
}
