#include <bits/stdc++.h>
using namespace std;
const long long int M = 2e5 + 10;
const long long int mod = 1e9 + 7;
const long long int infi = LLONG_MAX;
long long int ans, k, n, x, y, m, mymax = LLONG_MIN, mymin = LLONG_MAX, b, c, z,
                                  sum;
vector<long long int> v[M];
vector<long long int> vx, vy;
set<long long int> sx, sy;
long long int query(long long int node, long long int type) {
  if (type == 1) {
    cout << "A " << node << endl;
  } else
    cout << "B " << node << endl;
  long long int val;
  cin >> val;
  return val;
}
long long int dfs(long long int node, long long int parent,
                  long long int target) {
  long long int curr_dist = n;
  if (node == target) {
    return 0;
  }
  for (auto kk : v[node]) {
    if (kk != parent) {
      curr_dist = min(1 + dfs(kk, node, target), curr_dist);
    }
  }
  return curr_dist;
}
long long int dist(long long int node1, long long int node2) {
  return dfs(node1, node1, node2);
}
void solve() {
  long long int i, j;
  cin >> n;
  for (i = 1; i < n + 1; i++) v[i].clear();
  for (i = 1; i < n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  vx.clear();
  vy.clear();
  sx.clear();
  sy.clear();
  cin >> k;
  for (i = 1; i < k + 1; i++) {
    cin >> x;
    vx.push_back(x);
    sx.insert(x);
  }
  cin >> k;
  for (i = 1; i < k + 1; i++) {
    cin >> x;
    vy.push_back(x);
    sy.insert(x);
  }
  long long int node_in_x = query(vy[0], 2);
  if (sx.find(node_in_x) != sx.end()) {
    cout << "C " << node_in_x << endl;
    return;
  }
  long long int curr_node = -1, min_dist = n;
  for (auto node : vx) {
    long long int curr_dist = dist(node, node_in_x);
    if (curr_dist < min_dist) {
      min_dist = curr_dist;
      curr_node = node;
    }
  }
  long long int node_in_y = query(curr_node, 1);
  if (sy.find(node_in_y) != sy.end()) {
    cout << "C " << curr_node << endl;
  } else {
    cout << "C -1" << endl;
  }
}
int main() {
  long long int i, t, j;
  cin.tie(NULL);
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
