#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
inline void ckmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void ckmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const int maxn = 100000;
int n;
vector<int> g[maxn];
bool c[maxn];
int dfs(int p, int prev) {
  if (c[p]) return p;
  for (int z : g[p])
    if (z != prev) {
      int t = dfs(z, p);
      if (t >= 0) return t;
    }
  return -1;
}
int main() {
  std::ios::sync_with_stdio(false);
  int testcase;
  for (cin >> testcase; testcase > 0; testcase--) {
    cin >> n;
    for (int i = 0; i < (n); ++i) g[i].clear();
    for (int i = 0; i < (n - 1); ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    int n1, n2;
    for (int i = 0; i < (n); ++i) c[i] = false;
    cin >> n1;
    for (int i = 0; i < (n1); ++i) {
      int p;
      cin >> p;
      --p;
      c[p] = true;
    }
    cin >> n2;
    vector<int> b(n2);
    for (int i = 0; i < (n2); ++i) {
      cin >> b[i];
      --b[i];
    }
    printf("B %d\n", b[0] + 1);
    fflush(stdout);
    int key;
    cin >> key;
    --key;
    int other = dfs(key, -1);
    printf("A %d\n", other + 1);
    fflush(stdout);
    int pick;
    cin >> pick;
    --pick;
    bool ok = false;
    for (int i = 0; i < (n2); ++i)
      if (b[i] == pick) ok = true;
    if (ok)
      printf("C %d\n", other + 1);
    else
      printf("C -1\n");
    fflush(stdout);
  }
  return 0;
}
