#include <bits/stdc++.h>
using namespace std;
vector<int> G[1000];
bool used[1000];
bool my[1000];
int height[1000];
bool lee[1000];
int p[1000];
void dfs(int v, int h) {
  used[v] = true;
  height[v] = h;
  for (int i = 0; i < G[v].size(); ++i) {
    if (!used[G[v][i]]) {
      dfs(G[v][i], h + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int tests;
  cin >> tests;
  while (tests--) {
    for (int i = 0; i < 1000; ++i) {
      G[i].clear();
      used[i] = false;
      my[i] = false;
      height[i] = 0;
      lee[i] = false;
      p[i] = -1;
    }
    int n;
    cin >> 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);
    }
    dfs(0, 0);
    p[0] = -1;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < G[i].size(); ++j) {
        if (height[i] > height[G[i][j]]) {
          p[i] = G[i][j];
        } else {
          p[G[i][j]] = i;
        }
      }
    }
    int k1;
    int best = -1;
    cin >> k1;
    for (int i = 0; i < k1; ++i) {
      int a;
      cin >> a;
      a--;
      my[a] = true;
      if (best == -1 || height[best] > height[a]) {
        best = a;
      }
    }
    int k2;
    int someVert;
    cin >> k2;
    for (int i = 0; i < k2; ++i) {
      cin >> someVert;
      --someVert;
      lee[someVert] = true;
    }
    cout << "B " << someVert + 1 << endl;
    int his;
    cin >> his;
    --his;
    if (my[his] == true) {
      cout << "C " << his + 1 << endl;
      continue;
    }
    if (height[his] <= height[best]) {
      cout << "A " << best + 1 << endl;
      int kek;
      cin >> kek;
      --kek;
      if (lee[kek]) {
        cout << "C " << best + 1 << endl;
        continue;
      } else {
        cout << "C " << -1 << endl;
        continue;
      }
    } else {
      int lol = his;
      bool was = false;
      while (true) {
        lol = p[lol];
        if (lol == -1) break;
        if (my[lol] == true) {
          cout << "A " << lol + 1 << endl;
          int kek;
          cin >> kek;
          --kek;
          was = true;
          if (lee[kek]) {
            cout << "C " << lol + 1 << endl;
            break;
          } else {
            cout << "C " << -1 << endl;
            break;
          }
        }
      }
      if (!was) {
        cout << "A " << best + 1 << endl;
        int kek;
        cin >> kek;
        --kek;
        if (lee[kek]) {
          cout << "C " << best + 1 << endl;
          continue;
        } else {
          cout << "C " << -1 << endl;
          continue;
        }
      }
      continue;
    }
  }
  return 0;
}
