#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adjlist[1005];
bool b1[1005], b2[1005];
int dfs(int u, int par) {
  if (b1[u]) return u;
  for (auto v : adjlist[u]) {
    if (v == par) continue;
    int temp = dfs(v, u);
    if (temp != -1) return temp;
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  for (int test = 1; test <= t; ++test) {
    for (int i = 0; i < 1005; ++i) adjlist[i].clear();
    memset(b1, 0, sizeof(b1));
    memset(b2, 0, sizeof(b2));
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      cin >> a >> b;
      adjlist[a].push_back(b);
      adjlist[b].push_back(a);
    }
    int k1;
    cin >> k1;
    for (int i = 0; i < k1; ++i) {
      int x;
      cin >> x;
      b1[x] = 1;
    }
    int k2;
    cin >> k2;
    int node;
    for (int i = 0; i < k2; ++i) {
      int x;
      cin >> x;
      node = x;
      b2[x] = 1;
    }
    cout << "B " << node << endl;
    int x;
    cin >> x;
    if (x == -1) exit(0);
    node = dfs(x, 0);
    cout << "A " << node << endl;
    cin >> x;
    if (x == -1) exit(0);
    if (b2[x])
      cout << "C " << node << endl;
    else
      cout << "C -1" << endl;
  }
}
