#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
template <typename T>
void showArray(const T *arr, int sz) {
  for (int i = 0; i < sz; ++i) {
    cout << arr[i] << ' ';
  }
  cout << endl;
}
int readInt() {
  int ret = 0, k = 1;
  char c = getchar();
  if (c == '-') {
    k = -1;
  } else {
    ret = c - '0';
  }
  c = getchar();
  while (c != ' ' && c != '\n') {
    ret = ret * 10 + c - '0';
    c = getchar();
  }
  return k * ret;
}
const bool debug = false;
const int MAXN = 1e3 + 5, INF = 1e9;
const double pi = acos(-1);
int t, n, k1, k2, x[MAXN], y[MAXN];
vector<int> g[MAXN];
bool used[MAXN];
bool findx(int v) {
  int p = lower_bound(x, x + k1, v) - x;
  return p < k1 && x[p] == v;
}
bool findy(int v) {
  int p = lower_bound(y, y + k2, v) - y;
  return p < k2 && y[p] == v;
}
int dfs(int v) {
  used[v] = true;
  if (findx(v)) {
    return v;
  }
  for (auto &to : g[v]) {
    if (!used[to]) {
      int ret = dfs(to);
      if (ret != -1) return ret;
    }
  }
  return -1;
}
void solve() {
  int z, ansx, ansy;
  printf("B %d\n", y[0] + 1);
  fflush(stdout);
  scanf("%d", &z);
  --z;
  ansx = dfs(z);
  printf("A %d\n", ansx + 1);
  fflush(stdout);
  scanf("%d", &ansy);
  --ansy;
  if (findy(ansy)) {
    printf("C %d\n", ansx + 1);
    fflush(stdout);
    return;
  }
  printf("C -1\n");
  fflush(stdout);
}
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 0, v, u; i < n - 1; ++i) {
      scanf("%d %d", &v, &u);
      --v, --u;
      g[v].emplace_back(u);
      g[u].emplace_back(v);
    }
    scanf("%d", &k1);
    memset(x, 255, sizeof(int) * MAXN);
    for (int i = 0; i < k1; ++i) {
      scanf("%d", &x[i]);
      --x[i];
    }
    sort(x, x + k1);
    scanf("%d", &k2);
    memset(y, 255, sizeof(int) * MAXN);
    for (int i = 0; i < k2; ++i) {
      scanf("%d", &y[i]);
      --y[i];
    }
    sort(y, y + k2);
    memset(used, 0, sizeof(bool) * MAXN);
    solve();
    for (int i = 0; i < n; ++i) {
      g[i].clear();
    }
  }
  return 0;
}
