#include <bits/stdc++.h>
using namespace std;
const int limN = 1005;
int query(int tp, int pos) {
  printf("%c %d\n", tp + 'A', pos);
  fflush(stdout);
  if (tp != 2) {
    int N;
    scanf("%d", &N);
    if (N == -1) {
      exit(0);
    }
    return N;
  }
  return 0;
}
vector<int> adj[limN];
bool inA[limN], inB[limN];
int closestA(int pos, int pv = -1) {
  if (inA[pos]) return pos;
  int ans;
  for (const int sig : adj[pos])
    if (sig != pv) {
      ans = closestA(sig, pos);
      if (ans != -1) return ans;
    }
  return -1;
}
void testCase() {
  memset(inA, 0, sizeof(inA));
  memset(inB, 0, sizeof(inB));
  int N;
  int X, Y;
  scanf("%d", &N);
  for (int i = 1, a, b; i < N; i++) {
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  scanf("%d", &X);
  for (int i = 0, a; i < X; i++) {
    scanf("%d", &a);
    inA[a] = true;
  }
  scanf("%d", &Y);
  for (int i = 0, a; i < Y; i++) {
    scanf("%d", &a);
    inB[a] = true;
  }
  int p = -1;
  for (int i = 1; i <= N; i++) {
    if (!inB[i]) continue;
    p = closestA(query(1, i));
    break;
  }
  int w = query(0, p);
  query(2, inB[w] ? p : -1);
  for (int i = 1; i <= N; i++) adj[i].clear();
}
int main() {
  int tc;
  scanf("%d", &tc);
  for (int i = 0; i < tc; i++) testCase();
}
