#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<int> used;
set<int> x, y;
int bfs(int v) {
  fill(used.begin(), used.end(), 0);
  queue<int> q;
  q.push(v);
  used[v] = 1;
  while (q.size() > 0) {
    v = q.front();
    if (x.find(v) != x.end()) return v;
    q.pop();
    for (int to : g[v]) {
      if (!used[to]) {
        used[to] = 1;
        q.push(to);
      }
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, a, b, k;
    cin >> n;
    x.clear();
    y.clear();
    g.assign(n, vector<int>());
    used.assign(n, 0);
    for (int i = 0; i < n - 1; i++) {
      cin >> a >> b;
      a--;
      b--;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    cin >> k;
    for (int i = 0; i < k; i++) {
      cin >> a;
      a--;
      x.insert(a);
    }
    cin >> k;
    for (int i = 0; i < k; i++) {
      cin >> a;
      a--;
      y.insert(a);
    }
    b = *y.begin();
    cout << "B " << b + 1 << "\n";
    cin >> a;
    a--;
    if (x.find(a) != x.end()) {
      cout << "C " << a + 1 << "\n";
      continue;
    }
    a = bfs(a);
    cout << "A " << a + 1 << "\n";
    cin >> b;
    b--;
    if (y.find(b) != y.end()) {
      cout << "C " << a + 1 << "\n";
      continue;
    }
    cout << "C -1"
         << "\n";
  }
  return 0;
}
