#include <bits/stdc++.h>
using namespace std;
const long long N = (5e5) + 322;
const int INF = (int)(1e9);
const long long mod = 998244353;
const double eps = 1e-9;
int n, m, test, used[1111], col1[1111], par[1111], col[1111], ver;
vector<int> v[1111];
void dfs(int x, int p = -1) {
  if (col[x]) {
    ver = x;
    return;
  }
  for (auto it : v[x]) {
    if (it == p) continue;
    dfs(it, x);
  }
}
int getB(int x) {
  cout << "B ";
  fflush(stdout);
  cout << x << "\n";
  fflush(stdout);
  int ans;
  cin >> ans;
  return ans;
}
int getA(int x) {
  cout << "A ";
  fflush(stdout);
  cout << x << "\n";
  fflush(stdout);
  int ans;
  cin >> ans;
  return ans;
}
int main() {
  cin >> test;
  while (test--) {
    cin >> n;
    memset(used, 0, sizeof used);
    memset(col1, 0, sizeof col1);
    memset(par, 0, sizeof par);
    memset(col, 0, sizeof col);
    for (int i = 1; i <= n; ++i) v[i].clear();
    for (int i = 1; i <= n - 1; ++i) {
      int x, y;
      cin >> x >> y;
      v[x].push_back(y);
      v[y].push_back(x);
    }
    dfs(1);
    int k1;
    cin >> k1;
    for (int i = 1; i <= k1; ++i) {
      int x;
      cin >> x;
      col[x] = 1;
    }
    int k2;
    cin >> k2;
    int start = 0;
    for (int i = 1; i <= k2; ++i) {
      int x;
      cin >> x;
      col1[x] = 1;
      start = x;
    }
    int cur = getB(start);
    dfs(cur);
    if (col1[getA(ver)]) {
      cout << "C ";
      fflush(stdout);
      cout << ver << "\n";
      fflush(stdout);
    } else {
      cout << "C ";
      fflush(stdout);
      cout << -1 << "\n";
      fflush(stdout);
    }
  }
  return 0;
}
