#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int llINF = 0x3f3f3f3f3f3f3f;
int vis[1010];
int hgt[1010];
vector<int> good1;
vector<int> good2;
vector<int> nodes[1010];
void reset() {
  for (int i = 0; i < 1010; i++) nodes[i].clear();
  memset(vis, 0, sizeof(vis));
  memset(hgt, 0, sizeof(hgt));
  good1.clear();
  good2.clear();
}
void dfs(int v) {
  vis[v] = 1;
  for (auto x : nodes[v]) {
    if (vis[x]) continue;
    hgt[x] = 1 + hgt[v];
    dfs(x);
  }
}
void solve() {
  int n;
  cin >> n;
  reset();
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    nodes[a].push_back(b);
    nodes[b].push_back(a);
  }
  int k1;
  cin >> k1;
  for (int i = 0; i < k1; i++) {
    int x;
    cin >> x;
    good1.push_back(x);
  }
  int k2;
  cin >> k2;
  for (int i = 0; i < k2; i++) {
    int x;
    cin >> x;
    good2.push_back(x);
  }
  int other_root = good2[0];
  int my_root;
  cout << "B " << other_root << endl;
  cin >> my_root;
  fflush(stdout);
  dfs(my_root);
  int top_me;
  int mn_me = INF;
  for (auto x : good1) {
    if (hgt[x] >= mn_me) continue;
    top_me = x;
    mn_me = hgt[x];
  }
  int top_me_toliu;
  cout << "B " << top_me << endl;
  cin >> top_me_toliu;
  fflush(stdout);
  bool flag = false;
  for (auto x : good2) {
    if (x == top_me_toliu) flag = true;
  }
  if (!flag)
    cout << -1 << endl;
  else
    cout << "C " << top_me << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
}
