#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > e;
int d[1000], pr[1000];
void DFS(int x, int p, int dp) {
  d[x] = dp;
  pr[x] = p;
  for (int i = 0; i < e[x].size(); i++)
    if (e[x][i] != p) DFS(e[x][i], x, dp + 1);
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, a, b, k1, k2, ba[1000] = {}, c[1000] = {}, mn = 1001, ind = -1, x, y;
    cin >> n;
    e.resize(n);
    for (int j = 0; j < n; j++) e[j].clear();
    for (int j = 0; j < n - 1; j++) {
      cin >> a >> b;
      a--;
      b--;
      e[a].push_back(b);
      e[b].push_back(a);
    }
    DFS(0, -1, 0);
    cin >> k1;
    for (int j = 0; j < k1; j++) {
      cin >> x;
      ba[x - 1] = 1;
    }
    cin >> k2;
    for (int j = 0; j < k2; j++) {
      cin >> x;
      c[x - 1] = 1;
    }
    for (int j = 0; j < n; j++)
      if (ba[j] && d[j] < mn) {
        mn = d[j];
        ind = j;
      }
    cout << "B " << x << endl;
    cin >> x;
    x--;
    if (ba[x]) {
      cout << "C " << x + 1 << endl;
      continue;
    }
    while (x >= 0 && !ba[x]) x = pr[x];
    if (x >= 0) {
      cout << "A " << x + 1 << endl;
      cin >> y;
      y--;
      if (c[y])
        cout << "C " << x + 1 << endl;
      else
        cout << "C -1" << endl;
      continue;
    }
    cout << "A " << ind + 1 << endl;
    cin >> y;
    y--;
    if (c[y])
      cout << "C " << ind + 1 << endl;
    else
      cout << "C -1" << endl;
  }
}
