#include <bits/stdc++.h>
using namespace std;
const int N = 1123;
vector<int> g[N];
int ponta[N];
set<int> mine, his;
void dfs(int u, int p, int patrao) {
  if (mine.count(u)) {
    patrao = u;
  } else {
    ponta[u] = patrao;
  }
  for (int v : g[u]) {
    if (v == p) continue;
    dfs(v, u, patrao);
  }
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) g[i].clear();
    for (int i = 1; i <= n; i++) ponta[i] = 0;
    mine.clear();
    his.clear();
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      cin >> a >> b;
      g[a].emplace_back(b);
      g[b].emplace_back(a);
    }
    int k1;
    cin >> k1;
    for (int i = 0; i < k1; i++) {
      int x;
      cin >> x;
      mine.emplace(x);
    }
    int k2;
    cin >> k2;
    for (int i = 0; i < k2; i++) {
      int x;
      cin >> x;
      his.emplace(x);
    }
    dfs(*mine.begin(), 0, *mine.begin());
    cout << "B " << *(his.begin()) << endl;
    int who;
    cin >> who;
    if (mine.count(who)) {
      cout << "C " << who << endl;
    } else {
      cout << "A " << ponta[who] << endl;
      int dele;
      cin >> dele;
      if (his.count(dele)) {
        cout << "C " << ponta[who] << endl;
      } else {
        cout << "C -1" << endl;
      }
    }
  }
  return 0;
}
