#include <bits/stdc++.h>
using namespace std;
const int INF = 1231231234;
const int MOD = 1000000007;
const double EPS = 1e-8;
struct edge {
  int to;
};
int firstHit(vector<vector<edge>> &g, vector<int> &mine, int curr, int lim,
             int dist = 0, int prev = -1) {
  if (binary_search(mine.begin(), mine.end(), curr)) {
    return curr;
  } else if (dist == lim)
    return -1;
  for (edge e : g[curr])
    if (e.to != prev) {
      auto possible = firstHit(g, mine, e.to, lim, dist + 1, curr);
      if (possible != -1) return possible;
    }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<vector<edge>> g(n);
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      cin >> a >> b;
      --a, --b;
      g[a].push_back({b});
      g[b].push_back({a});
    }
    int k1;
    cin >> k1;
    vector<int> mine(k1);
    for (int i = 0; i < k1; i++) {
      cin >> mine[i];
      --mine[i];
    }
    sort(mine.begin(), mine.end());
    int k2;
    cin >> k2;
    vector<int> others(k2);
    for (int i = 0; i < k2; i++) {
      cin >> others[i];
      --others[i];
    }
    sort(others.begin(), others.end());
    cout << "B " << others[0] + 1 << endl;
    int myLabel;
    cin >> myLabel;
    if (myLabel == -1) exit(0);
    --myLabel;
    if (binary_search(mine.begin(), mine.end(), myLabel)) {
      cout << "C " << myLabel + 1 << endl;
    } else {
      int check = firstHit(g, mine, myLabel, k2);
      if (check == -1) {
        cout << "C -1" << endl;
      } else {
        cout << "A " << check + 1 << endl;
        int hisLabel;
        cin >> hisLabel;
        if (hisLabel == -1) exit(0);
        --hisLabel;
        if (binary_search(others.begin(), others.end(), hisLabel)) {
          cout << "C " << check + 1 << endl;
        } else {
          cout << "C -1" << endl;
        }
      }
    }
  }
}
