#include <bits/stdc++.h>
using namespace std;
int a, b, c, n, m, k = 0, T, x[100010], y[100010], f[100010], head[100010],
                   maxx = -0x3f3f3f3f;
struct node {
  int u, v, Next;
} t[2 * 100010];
void add(int u, int v) {
  t[++k].v = v;
  t[k].Next = head[u];
  head[u] = k;
}
void dfs(int u, int fa) {
  if (!x[u]) f[u] = f[fa];
  for (int i = head[u]; i; i = t[i].Next) {
    int v = t[i].v;
    if (v == fa) continue;
    dfs(v, u);
  }
}
int main() {
  scanf("%d", &T);
  while (T--) {
    int k1, k2;
    scanf("%d", &n);
    for (long long i = 1; i <= n; i++) head[i] = x[i] = y[i] = 0, f[i] = i;
    k = 0;
    for (long long i = 1; i <= n - 1; i++)
      scanf("%d%d", &a, &b), add(a, b), add(b, a);
    scanf("%d", &k1);
    for (long long i = 1; i <= k1; i++) scanf("%d", &a), x[a] = 1, b = a;
    scanf("%d", &k2);
    for (long long i = 1; i <= k2; i++) scanf("%d", &a), y[a] = 1, c = a;
    dfs(b, 0);
    int d;
    cout << "B " << c << endl;
    scanf("%d", &a);
    cout << "A " << f[a] << endl;
    scanf("%d", &d);
    if (y[d])
      cout << "C " << f[a] << endl;
    else
      cout << "C -1" << endl;
  }
}
