#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int x;
  int y;
} H;
int i, k, m, n, p, sz, t, x[1005], y[1005];
int pv[1005], vi[1005];
H e[2040];
int C(H a, H b) { return a.x < b.x; }
void BP(void);
void S(void);
void dfs(int v);
int main() {
  for (cin >> t; t--;) {
    S();
    BP();
    for (cin >> m; m--;) {
      cin >> k;
      x[k] = 1;
    }
    for (cin >> m; m--;) {
      cin >> k;
      y[k] = 1;
    }
    cout << "B " << k << endl;
    fflush(stdout);
    cin >> m;
    dfs(m);
    cout << "A " << k << endl;
    fflush(stdout);
    cin >> m;
    cout << "C " << (y[m] ? k : -1) << endl;
    fflush(stdout);
    for (i = 0; i++ < n;) vi[i] = x[i] = y[i] = 0;
  }
}
void BP(void) {
  for (int i = p = 0; ++i < sz;) {
    if (e[i].x > e[i - 1].x) {
      for (int j = e[i - 1].x; j++ < e[i].x;) {
        pv[j] = i;
      }
    }
  }
  for (int j = e[sz - 1].x; j++ < n + 1;) pv[j] = sz;
}
void S(void) {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &e[i].x, &e[i].y);
    e[i + n - 1].x = e[i].y;
    e[i + n - 1].y = e[i].x;
  }
  sz = 2 * n - 2;
  sort(e, e + sz, C);
}
void dfs(int v) {
  vi[v] = 1;
  if (x[v]) {
    p = 1;
    k = v;
    return;
  }
  for (int i = pv[v]; !p && i < pv[v + 1]; i++) {
    if (!vi[e[i].y]) dfs(e[i].y);
  }
}
