#include <bits/stdc++.h>
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using namespace std;
class Solve {
 public:
  int n;
  vector<vector<int>> treeone;
  vector<int> dist;
  vector<int> tapu;
  vector<int> tapi;
  void input() {
    cin >> n;
    treeone.resize(n + 1);
    for (int i = int(0); i < int(n - 1); i++) {
      int a, b;
      cin >> a >> b;
      treeone[a].push_back(b);
      treeone[b].push_back(a);
    }
    int k;
    cin >> k;
    for (int i = int(0); i < int(k); i++) {
      int tmp;
      cin >> tmp;
      tapu.push_back(tmp);
    }
    cin >> k;
    for (int i = int(0); i < int(k); i++) {
      int tmp;
      cin >> tmp;
      tapi.push_back(tmp);
    }
  }
  void query(char c, int n) { cout << c << " " << n << endl; }
  void bfs(int s) {
    dist.resize(n + 1, (1 << 30) - 1);
    queue<int> que;
    dist[s] = 0;
    que.push(s);
    while (!que.empty()) {
      int top = que.front();
      que.pop();
      for (auto e : treeone[top]) {
        int nd = dist[top] + 1;
        if (dist[e] > nd) {
          dist[e] = nd;
          que.push(e);
        }
      }
    }
  }
  void solve() {
    input();
    query('B', tapi[0]);
    int start;
    cin >> start;
    bfs(start);
    int r = -1;
    int min_dist = (1 << 30) - 1;
    for (auto e : tapu) {
      if (dist[e] < min_dist) {
        r = e;
        min_dist = dist[e];
      }
    }
    if (r == -1) {
      query('C', -1);
      return;
    }
    query('A', r);
    int tapya;
    cin >> tapya;
    if (find(begin(tapi), end(tapi), tapya) != tapi.end()) {
      query('C', r);
    } else {
      query('C', -1);
    }
  }
};
int main() {
  int t;
  cin >> t;
  while (t--) {
    Solve().solve();
  }
  return 0;
}
