#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  void solve(vector<pair<int, int>>& edges, vector<int>& xs, vector<int>& ys,
             int n) {
    vector<vector<int>> graph(n + 1);
    for (auto& p : edges) {
      int u = p.first, v = p.second;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    cout << "B " << ys[0] << endl;
    fflush(stdout);
    int root = -1;
    cin >> root;
    vector<int> dis(n + 1, INT_MAX);
    dis[root] = 0;
    queue<int> q;
    q.push(root);
    while (!q.empty()) {
      auto u = q.front();
      q.pop();
      int d = dis[u];
      for (auto v : graph[u]) {
        if (dis[v] > d + 1) {
          dis[v] = d + 1;
          q.push(v);
        }
      }
    }
    int x = -1;
    for (auto v : xs) {
      if (x == -1 || dis[x] > dis[v]) {
        x = v;
      }
    }
    cout << "A " << x << endl;
    fflush(stdout);
    int y = -1;
    cin >> y;
    bool found = false;
    for (auto v : ys) {
      if (v == y) {
        found = true;
        break;
      }
    }
    if (found) {
      cout << "C " << x << endl;
    } else {
      cout << "C " << -1 << endl;
    }
    fflush(stdout);
    return;
  }
};
int main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution sol;
  int t;
  cin >> t;
  while (t-- > 0) {
    int n;
    cin >> n;
    vector<pair<int, int>> edges;
    edges.reserve(n - 1);
    for (int i = 0, u = 0, v = 0; i < n - 1; ++i) {
      cin >> u >> v;
      edges.emplace_back(u, v);
    }
    int k;
    cin >> k;
    vector<int> xs(k);
    for (int i = 0; i < k; ++i) {
      cin >> xs[i];
    }
    cin >> k;
    vector<int> ys(k);
    for (int i = 0; i < k; ++i) {
      cin >> ys[i];
    }
    sol.solve(edges, xs, ys, n);
  }
  return 0;
}
