#include <bits/stdc++.h>
using namespace std;
vector<int> G[1010];
vector<int> label1, label2;
int dfs(int v, int parent) {
  for (auto num : label1) {
    if (v == num) return v;
  }
  for (auto to : G[v]) {
    if (to == parent) continue;
    int tmp = dfs(to, v);
    if (tmp != -1) return tmp;
  }
  return -1;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int cnt = 0; cnt < t; cnt++) {
    for (int i = 0; i < 1010; i++) G[i].clear();
    label1.clear();
    label2.clear();
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
      int s, t;
      cin >> s >> t;
      G[s].push_back(t);
      G[t].push_back(s);
    }
    int k1;
    cin >> k1;
    for (int i = 0; i < k1; i++) {
      int tmp;
      cin >> tmp;
      label1.push_back(tmp);
    }
    int k2;
    cin >> k2;
    for (int i = 0; i < k2; i++) {
      int tmp;
      cin >> tmp;
      label2.push_back(tmp);
    }
    cout << "B " << label2[0] << endl << flush;
    int v;
    cin >> v;
    cout << "A " << dfs(v, -1) << endl << flush;
    cin >> v;
    bool find = false;
    for (auto num : label2) {
      if (v == num) {
        cout << "C 1" << endl << flush;
        find = true;
        break;
      }
    }
    if (!find) cout << "C -1" << endl << flush;
  }
  return 0;
}
