#include <bits/stdc++.h>
class TaskD {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int t;
    in >> t;
    for (int caseNo = 0; caseNo < t; ++caseNo) {
      int n;
      in >> n;
      std::vector<std::vector<int> > tree(n);
      for (int i = 0; i < n - 1; ++i) {
        int a, b;
        in >> a >> b;
        a--;
        b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
      }
      int k1;
      in >> k1;
      std::set<int> my;
      for (int i = 0; i < k1; ++i) {
        int a;
        in >> a;
        a--;
        my.insert(a);
      }
      int k2;
      in >> k2;
      std::set<int> his;
      for (int i = 0; i < k2; ++i) {
        int a;
        in >> a;
        a--;
        his.insert(a);
      }
      int witness = *(his.begin());
      out << "B " << witness + 1 << "\n";
      out.flush();
      int my_witness;
      in >> my_witness;
      my_witness--;
      if (my.find(my_witness) != my.end()) {
        out << "C " << my_witness + 1 << "\n";
        out.flush();
        continue;
      }
      std::queue<int> q;
      std::vector<int> visited(n, 0);
      q.push(my_witness);
      visited[my_witness] = 1;
      int v;
      while (!q.empty()) {
        v = q.front();
        q.pop();
        if (my.find(v) != my.end()) {
          break;
        }
        for (int j = 0; j < (int)tree[v].size(); ++j) {
          int u = tree[v][j];
          if (visited[u] == 0) {
            visited[u] = 1;
            q.push(u);
          }
        }
      }
      out << "A " << v + 1 << "\n";
      out.flush();
      int hisV;
      in >> hisV;
      hisV--;
      if (his.find(hisV) != his.end()) {
        out << "C " << v + 1 << "\n";
        out.flush();
      } else {
        out << "C " << -1 << "\n";
        out.flush();
      }
    }
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout << std::fixed;
  std::cout << std::setprecision(15);
  TaskD solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
