#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int test, n, k1, k2;
vector<int> e[N];
set<int> ms1, ms2;
int dfs(int u, int p) {
  if (ms1.find(u) != ms1.end()) return u;
  for (int v : e[u]) {
    if (v != p) {
      dfs(v, u);
    }
  }
  return -1;
}
void solve() {
  cin >> n;
  ms1.clear();
  ms2.clear();
  for (int i = 1; i <= n; ++i) {
    e[i].clear();
  }
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  cin >> k1;
  for (int i = 1; i <= k1; ++i) {
    int x;
    cin >> x;
    ms1.insert(x);
  }
  cin >> k2;
  for (int i = 1; i <= k2; ++i) {
    int x;
    cin >> x;
    ms2.insert(x);
  }
  if (ms1.size() <= 5) {
    for (int x : ms1) {
      cout << "A " << x << "\n";
      fflush(stdout);
      int ans;
      cin >> ans;
      if (ms2.find(ans) != ms2.end()) {
        cout << "C " << x << "\n";
        fflush(stdout);
        return;
      }
    }
    cout << "C -1\n";
    fflush(stdout);
    return;
  }
  if (ms2.size() <= 5) {
    for (int x : ms2) {
      cout << "B " << x << "\n";
      fflush(stdout);
      int ans;
      cin >> ans;
      if (ms1.find(ans) != ms1.end()) {
        cout << "C " << ans << "\n";
        fflush(stdout);
        return;
      }
    }
    cout << "C -1\n";
    fflush(stdout);
    return;
  }
  int u, ans;
  u = *ms2.begin();
  ms2.erase(u);
  cout << "B " << u << "\n";
  fflush(stdout);
  cin >> ans;
  if (ms1.find(ans) != ms1.end()) {
    cout << "C " << ans << "\n";
    fflush(stdout);
    return;
  }
  u = dfs(ans, 0);
  cout << "A " << u << "\n";
  fflush(stdout);
  cin >> ans;
  if (ms2.find(ans) != ms2.end()) {
    cout << "C " << u << "\n";
    fflush(stdout);
    return;
  }
  cout << "C -1\n";
  fflush(stdout);
  return;
}
int main() {
  cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}
