#include <bits/stdc++.h>
using namespace std;
template <class T>
T gi() {
  T x = 0;
  bool f = 0;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = 1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f ? -x : x;
}
const int N = 1010;
vector<int> e[N];
int in1[N], in2[N];
int dfs(int u, int ff) {
  if (in1[u]) return u;
  for (auto v : e[u])
    if (v != ff) {
      int d = dfs(v, u);
      if (d) return d;
    }
  return 0;
}
void solve() {
  int n = gi<int>();
  for (int i = 1; i <= n; i++) e[i].clear();
  for (int i = 1; i < n; i++) {
    int x = gi<int>(), y = gi<int>();
    e[x].push_back(y), e[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) in1[i] = in2[i] = 0;
  int m = gi<int>();
  for (int i = 1; i <= m; i++) in1[gi<int>()] = 1;
  m = gi<int>();
  for (int i = 1; i <= m; i++) in2[gi<int>()] = 1;
  for (int i = 1; i <= n; i++)
    if (in2[i]) {
      printf("B %d\n", i);
      fflush(stdout);
      int x = gi<int>(), y = dfs(x, 0);
      printf("A %d\n", y);
      fflush(stdout);
      x = gi<int>();
      if (in2[x]) {
        printf("C %d\n", y);
        fflush(stdout);
        return;
      } else
        break;
    }
  puts("C -1");
  fflush(stdout);
  return;
}
int main() {
  int T = gi<int>();
  while (T--) solve();
  return 0;
}
