#include <bits/stdc++.h>
using namespace std;
const int M = 10050;
struct edge {
  int to;
  int next;
} edges[M];
int head[M];
int num_e = -1;
void add_e(int a, int b) {
  num_e++;
  edges[num_e].to = b;
  edges[num_e].next = head[a];
  head[a] = num_e;
}
unordered_map<int, bool> mpa, mpb;
int dfs(int node, int last) {
  if (mpa[node]) {
    return node;
  }
  for (int i = head[node]; i != -1; i = edges[i].next) {
    if (edges[i].to == last) {
      continue;
    }
    int temp = dfs(edges[i].to, node);
    if (temp != -1) {
      return temp;
    }
  }
  return -1;
}
int main() {
  int t, n, a, b, k1, k2;
  cin >> t;
  while (t--) {
    num_e = -1;
    cin >> n;
    memset(head, -1, sizeof(int) * (n + 1));
    mpa.clear();
    mpb.clear();
    for (int i = 0; i < n - 1; i++) {
      cin >> a >> b;
      add_e(a, b);
      add_e(b, a);
    }
    cin >> k1;
    int temp;
    for (int i = 0; i < k1; i++) {
      cin >> temp;
      mpa[temp] = true;
    }
    cin >> k2;
    for (int i = 0; i < k2; i++) {
      cin >> temp;
      mpb[temp] = true;
    }
    cout << "B " << mpb.begin()->first << endl;
    cout.flush();
    int x;
    cin >> x;
    if (mpa[x]) {
      cout << "C " << x << endl;
      cout.flush();
    } else {
      int ans = dfs(x, -100);
      if (ans == -1) {
        cout << "C -1" << endl;
        cout.flush();
      } else {
        cout << "A " << ans << endl;
        cout.flush();
        int node;
        cin >> node;
        if (mpb[node]) {
          cout << "C " << ans << endl;
          cout.flush();
        } else {
          cout << "C -1" << endl;
          cout.flush();
        }
      }
    }
  }
  return 0;
}
