#include <bits/stdc++.h>
using std::deque;
using std::make_pair;
using std::map;
using std::max;
using std::min;
using std::pair;
using std::set;
using std::string;
using std::vector;
int getCloses(int his, std::vector<int>& mine,
              std::vector<std::vector<int> >& edges, int gs) {
  --his;
  vector<bool> reached(gs, false);
  static vector<int> process;
  process.clear();
  process.push_back(his);
  int processIdx = 0;
  reached[his] = true;
  while (process.size() > processIdx) {
    auto x = process[processIdx];
    ++processIdx;
    if (std::find(mine.begin(), mine.end(), x + 1) != mine.end()) {
      return x + 1;
    }
    for (auto y : edges[x]) {
      if (!reached[y]) {
        reached[y] = true;
        process.push_back(y);
      }
    }
  }
}
int main() {
  int t;
  scanf("%d", &t);
  std::vector<std::vector<int> > g(1000);
  std::vector<int> mine, his;
  for (int ddd = 0; ddd < t; ++ddd) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
      g[i].clear();
    }
    for (int i = 0; i < n - 1; ++i) {
      int x, y;
      scanf("%d%d", &x, &y);
      --x;
      --y;
      g[x].push_back(y);
      g[y].push_back(x);
    }
    int ms;
    scanf("%d", &ms);
    mine.resize(ms);
    for (auto& x : mine) {
      scanf("%d", &x);
    }
    scanf("%d", &ms);
    his.resize(ms);
    for (auto& x : his) {
      scanf("%d", &x);
    }
    std::cout << "B " << his.front() << std::endl;
    std::cout.flush();
    int ownedByHim;
    scanf("%d", &ownedByHim);
    if (std::find(mine.begin(), mine.end(), ownedByHim) != mine.end()) {
      std::cout << "C " << ownedByHim << std::endl;
      std::cout.flush();
      continue;
    }
    int closest = getCloses(ownedByHim, mine, g, n);
    std::cout << "A " << closest << std::endl;
    std::cout.flush();
    int closesInHim;
    scanf("%d", &closesInHim);
    if (std::find(his.begin(), his.end(), closesInHim) != his.end()) {
      std::cout << "C " << closest << std::endl;
      std::cout.flush();
    } else {
      std::cout << "C " << -1 << std::endl;
      std::cout.flush();
    }
  }
}
