#include <bits/stdc++.h>
using namespace std;
int T, x, y, n, m, k, v[400000];
bool t[400000];
vector<int> p[400000];
int dfs(int x) {
  if (v[x] == 2) return x;
  v[x] = 0;
  for (auto i : p[x])
    if (v[i]) {
      int r = dfs(i);
      if (r) return r;
    }
  return 0;
}
int main() {
  for (scanf("%d", &T); T; T--) {
    scanf("%d", &n);
    for (int i = (1); i <= (n); ++i) {
      p[i].clear();
      t[i] = 0;
      v[i] = 1;
    }
    for (int i = (1); i <= (n - 1); ++i) {
      scanf("%d%d", &x, &y);
      p[x].push_back(y);
      p[y].push_back(x);
    }
    scanf("%d", &m);
    for (int i = (1); i <= (m); ++i) {
      scanf("%d", &x);
      v[x] = 2;
    }
    scanf("%d", &k);
    for (int i = (1); i <= (k); ++i) {
      scanf("%d", &x);
      t[x] = 1;
    }
    printf("B %d\n", x);
    fflush(stdout);
    scanf("%d", &x);
    x = dfs(x);
    printf("A %d\n", x);
    fflush(stdout);
    scanf("%d", &y);
    if (t[y])
      printf("C %d\n", x);
    else
      printf("C -1\n");
    fflush(stdout);
  }
}
