#include <bits/stdc++.h>
using namespace std;
vector<int> used;
vector<vector<int>> g;
vector<int> check;
long long close;
void dfs(int v) {
  if (check[v] == 1 && close == -1) {
    close = v;
  }
  used[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    if (used[g[v][i]] == 0) {
      dfs(g[v][i]);
    }
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  for (int u = 0; u < t; u++) {
    used.clear();
    g.clear();
    check.clear();
    close = -1;
    long long int n, ans = -1;
    ;
    vector<int> h;
    cin >> n;
    for (int i = 0; i <= n; i++) {
      g.push_back(h);
      check.push_back(0);
      used.push_back(0);
    }
    for (int i = 0; i < n - 1; i++) {
      int x, y;
      cin >> x >> y;
      g[x].push_back(y);
      g[y].push_back(x);
    }
    int k1;
    cin >> k1;
    for (int i = 0; i < k1; i++) {
      int z;
      cin >> z;
      check[z] = 1;
    }
    int k2;
    cin >> k2;
    vector<int> his;
    for (int i = 0; i < k2; i++) {
      int z;
      cin >> z;
      his.push_back(z);
    }
    cout << "B " << his[0] << endl;
    int num;
    cin >> num;
    if (check[num] == 1) {
      ans = num;
    }
    if (ans == -1) {
      dfs(num);
      cout << "A " << close << endl;
      int y;
      cin >> y;
      for (int i = 0; i < his.size(); i++) {
        if (his[i] == y) ans = close;
      }
    }
    cout << "C " << ans << endl;
  }
}
