#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 1;
int T, n, mark1[maxn], mark2[maxn], k, q, ch, w;
vector<int> e[maxn];
void dfs(int v, int p) {
  if (mark1[v] == 1 && ch == 0) {
    ch = v;
  }
  for (auto u : e[v]) {
    if (u != p) {
      dfs(u, v);
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> T;
  for (int i = 1; i <= T; i++) {
    for (int i = 1; i < maxn; i++) {
      e[i].clear();
      mark1[i] = 0;
      mark2[i] = 0;
    }
    cin >> n;
    for (int i = 1; i < n; i++) {
      int tmp1, tmp2;
      cin >> tmp1 >> tmp2;
      e[tmp1].push_back(tmp2);
      e[tmp2].push_back(tmp1);
    }
    cin >> k;
    for (int i = 1; i <= k; i++) {
      int tmp1;
      cin >> tmp1;
      mark1[tmp1] = 1;
    }
    cin >> k;
    for (int i = 1; i <= k; i++) {
      int tmp1;
      cin >> tmp1;
      q = tmp1;
      mark2[tmp1] = 1;
    }
    cout << "B " << q << endl;
    cout << flush;
    cin >> w;
    ch = 0;
    dfs(w, 0);
    cout << "A " << ch << endl;
    cout << flush;
    cin >> w;
    if (mark2[w] == 1) {
      cout << "C " << ch << endl;
    } else {
      cout << "C " << -1 << endl;
    }
    cout << flush;
  }
  return 0;
}
