#include <bits/stdc++.h>
using namespace std;
int main() {
  int w;
  cin >> w;
  for (int z = 0; z < w; z++) {
    int n, k1, k2;
    cin >> n;
    vector<int> V[n];
    for (int i = 1; i < n; i++) {
      int a, b;
      cin >> a >> b;
      V[a - 1].push_back(b - 1);
      V[b - 1].push_back(a - 1);
    }
    int t;
    cin >> k1;
    bool BS[n];
    bool K1[n];
    for (int i = 0; i < n; i++) K1[i] = BS[i] = 0;
    for (int i = 0; i < k1; i++) {
      cin >> t;
      K1[t - 1] = 1;
    }
    cin >> k2;
    bool K2[n];
    for (int i = 0; i < n; i++) K2[i] = 0;
    for (int i = 0; i < k2; i++) {
      cin >> t;
      K2[t - 1] = 1;
    }
    int b0;
    cout << "B " << t << endl;
    cout.flush();
    cin >> b0;
    int x;
    queue<int> Q;
    Q.push(b0 - 1);
    while (1) {
      x = Q.front();
      Q.pop();
      if (BS[x]) continue;
      BS[x] = 1;
      if (K1[x]) break;
      for (int y : V[x]) Q.push(y);
    }
    int a0;
    cout << "A " << x + 1 << endl;
    cout.flush();
    cin >> a0;
    if (K2[a0 - 1])
      cout << "C " << x + 1 << endl;
    else
      cout << "C -1" << endl;
  }
}
