#include <bits/stdc++.h>
using namespace std;
int askB(int n) {
  cout << "B " << n << '\n';
  fflush(stdout);
  int a;
  cin >> a;
  return a;
}
int askA(int n) {
  cout << "A " << n << '\n';
  fflush(stdout);
  int a;
  cin >> a;
  return a;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<int> > tree(n + 1);
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      cin >> a >> b;
      tree[a].push_back(b);
      tree[b].push_back(a);
    }
    int k1;
    cin >> k1;
    set<int> mine;
    for (int i = 0; i < k1; i++) {
      int a;
      cin >> a;
      mine.insert(a);
    }
    int k2;
    cin >> k2;
    set<int> other;
    for (int i = 0; i < k2; i++) {
      int a;
      cin >> a;
      other.insert(a);
    }
    int st = askB(*(other.begin()));
    int vis[n + 1];
    int dist[n + 1];
    memset(vis, 0, sizeof(vis));
    memset(dist, 0, sizeof(dist));
    stack<int> stc;
    stc.push(st);
    bool ans = false;
    while (!stc.empty()) {
      int top = stc.top();
      stc.pop();
      if (vis[top]) continue;
      vis[top] = 1;
      if (mine.find(top) != mine.end() && dist[top] < k2) {
        int here = askA(top);
        if (other.find(here) != other.end()) {
          ans = true;
          cout << "C " << top << '\n';
        }
        break;
      }
      for (auto it : tree[top]) {
        if (vis[it]) continue;
        dist[it] = dist[top] + 1;
        stc.push(it);
      }
    }
    if (!ans) {
      cout << "C -1" << '\n';
    }
  }
  return 0;
}
