#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 5;
struct ed {
  int from, to, nxt;
  void clr() {
    from = 0;
    to = 0;
    nxt = 0;
  }
} edge[N << 1];
int head[N], cnt;
bool my[N], your[N];
inline void ad(int x, int y) {
  edge[++cnt].to = y;
  edge[cnt].nxt = head[x];
  head[x] = cnt;
}
inline int dfs(int num, int fa) {
  if (my[num]) return num;
  for (register int i = head[num]; i; i = edge[i].nxt) {
    if (edge[i].to == fa) continue;
    int temp = dfs(edge[i].to, num);
    if (temp != -1) return temp;
  }
  return -1;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n, tmp, gdgs, root;
    cin >> n;
    memset(head, 0, sizeof(head));
    for (register int i = 1; i <= (n << 1); ++i) edge[i].clr();
    memset(my, 0, sizeof(my));
    memset(your, 0, sizeof(your));
    cnt = 0;
    for (register int i = 1; i <= n - 1; ++i) {
      int x, y;
      cin >> x >> y;
      ad(x, y);
      ad(y, x);
    }
    cin >> tmp;
    for (register int i = 1; i <= tmp; ++i) cin >> gdgs, my[gdgs] = 1;
    cin >> tmp;
    for (register int i = 1; i <= tmp; ++i) cin >> gdgs, your[gdgs] = 1;
    cout << "B " << gdgs << endl;
    cout.flush();
    cin >> root;
    if (my[root]) {
      cout << "C " << root << endl;
      cout.flush();
      continue;
    }
    int ques = dfs(root, 0);
    if (ques == -1) {
      cout << "C -1\n";
      cout.flush();
      continue;
    }
    cout << "A " << ques << endl;
    cout.flush();
    int as;
    cin >> as;
    if (your[as]) {
      cout << "C " << ques << endl;
      cout.flush();
      continue;
    }
    cout << "C -1\n";
    cout.flush();
  }
  return 0;
}
