#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
template <typename T>
using Pair = array<T, 2>;
int get_y(int x) {
  cout << "A " << x << endl;
  int res;
  cin >> res;
  return res;
}
int get_x(int y) {
  cout << "B " << y << endl;
  int res;
  cin >> res;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<int>> g(n + 1);
    for (int i = 0; i < (int)n - 1; i++) {
      int a, b;
      cin >> a >> b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    int k1;
    cin >> k1;
    vector<int> x(k1);
    set<int> xs;
    for (int i = 0; i < (int)k1; i++) {
      cin >> x[i];
      xs.insert(x[i]);
    }
    int k2;
    cin >> k2;
    vector<int> y(k2);
    set<int> ys;
    for (int i = 0; i < (int)k2; i++) {
      cin >> y[i];
      ys.insert(y[i]);
    }
    int ss = get_x(y[0]);
    auto bfs = [&](int s) {
      vector<int> used(n + 1);
      queue<int> q;
      q.push(s);
      used[s] = true;
      if (xs.count(s)) {
        return s;
      }
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto& u : g[v]) {
          if (used[u]) {
            continue;
          }
          if (xs.count(u)) {
            return u;
          }
          q.push(u);
          used[u] = true;
        }
      }
      return -1;
    };
    int xx = bfs(ss);
    int yy = get_y(xx);
    cout << "C ";
    if (ys.count(yy)) {
      cout << xx << endl;
    } else {
      cout << -1 << endl;
    }
  }
}
