#include <bits/stdc++.h>
using namespace std;
long long t, n, i, b[1010], ta, tb, k1, a[1010], tem, x[1010], y[1010], k2, tom;
vector<long long> v[1010];
void dfs(long long aa, long long bb) {
  b[aa] = bb;
  long long ii;
  for (ii = 0; ii < v[aa].size(); ii++)
    if (!b[v[aa][ii]]) dfs(v[aa][ii], bb);
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (i = 1; i <= n; i++) v[i].clear();
    for (i = 1; i <= n; i++) b[i] = 0;
    for (i = 1; i < n; i++) {
      cin >> ta >> tb;
      v[ta].push_back(tb);
      v[tb].push_back(ta);
    }
    for (i = 1; i <= n; i++) b[i] = 0;
    for (i = 1; i <= n; i++) x[i] = 0;
    for (i = 1; i <= n; i++) y[i] = 0;
    cin >> k1;
    for (i = 1; i <= k1; i++) {
      cin >> a[i];
      b[a[i]] = a[i];
      x[a[i]] = 1;
    }
    for (i = 1; i <= k1; i++) dfs(a[i], a[i]);
    cin >> k2;
    for (i = 1; i <= k2; i++) {
      cin >> ta;
      y[ta] = 1;
    }
    cout << "B " << ta << endl;
    cin >> tem;
    if (x[tem])
      cout << "C " << tem << endl;
    else {
      cout << "A " << b[tem] << endl;
      cin >> tom;
      if (y[tom])
        cout << "C " << b[tem] << endl;
      else
        cout << "C " << -1 << endl;
    }
  }
}
