#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graph;
vector<bool> used;
set<int> tree1;
set<int> tree2;
int dfs(int u) {
  if (used[u]) {
    return 0;
  }
  used[u] = true;
  if (tree1.find(u) != tree1.end()) {
    return u;
  }
  for (int x : graph[u]) {
    int k = dfs(x);
    if (k != 0) {
      return k;
    }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    graph.assign(n + 1, vector<int>(0));
    used.assign(n + 1, false);
    tree1.clear();
    tree2.clear();
    for (int i = 0; i < n - 1; i++) {
      int u, v;
      cin >> u >> v;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    int k1;
    cin >> k1;
    for (int i = 0; i < k1; i++) {
      int u;
      cin >> u;
      tree1.insert(u);
    }
    int k2;
    cin >> k2;
    for (int i = 0; i < k2; i++) {
      int u;
      cin >> u;
      tree2.insert(u);
    }
    cout << "B " << *tree2.begin() << endl;
    int x;
    cin >> x;
    int t1 = dfs(x);
    cout << "A " << t1 << endl;
    int y;
    cin >> y;
    if (tree2.find(y) != tree2.end()) {
      cout << "C " << t1 << endl;
    } else {
      cout << "C " << -1 << endl;
    }
  }
  return 0;
}
