#include <bits/stdc++.h>
using namespace std;
const long long int INF = 10000000000000000;
int MOD(int a, int b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}
int max3(int a, int b, int c) { return max(c, max(a, b)); }
int min3(int a, int b, int c) { return min(a, min(b, c)); }
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
int logg(int a) {
  int x = 0;
  while (a > 1) {
    x++;
    a /= 2;
  }
  return x;
}
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int abso(int x) {
  if (x < 0) {
    return -x;
  }
  return x;
}
long long int ceiling(long long int a, long long int b) {
  if (a % b == 0) {
    return a / b;
  } else {
    return a / b + 1;
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<int> > adj(n + 1);
    for (int i = 0; i < n - 1; i++) {
      int x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    int k1;
    cin >> k1;
    vector<int> x(k1);
    for (int i = 0; i < k1; i++) {
      cin >> x[i];
    }
    sort(x.begin(), x.end());
    int k2;
    cin >> k2;
    vector<int> y(k2);
    for (int i = 0; i < k2; i++) {
      cin >> y[i];
    }
    sort(y.begin(), y.end());
    cout << 'B' << ' ' << y[0] << endl;
    int in;
    cin >> in;
    queue<int> Q;
    Q.push(in);
    if (binary_search(x.begin(), x.end(), in)) {
      cout << "C" << ' ' << in << endl;
      continue;
    }
    vector<int> visited;
    visited.resize(n + 1, 0);
    visited[in] = 1;
    bool found = false;
    int an;
    while (!Q.empty()) {
      int tmp = Q.front();
      Q.pop();
      for (int j = 0; j < adj[tmp].size(); j++) {
        if (binary_search(x.begin(), x.end(), adj[tmp][j])) {
          found = true;
          an = adj[tmp][j];
          break;
        } else {
          if (!visited[adj[tmp][j]]) {
            Q.push(adj[tmp][j]);
            visited[adj[tmp][j]] = 1;
          } else {
          }
        }
      }
      if (found) {
        break;
      }
    }
    if (!found) {
      cout << "C" << ' ' << -1 << endl;
    } else {
      cout << "A" << ' ' << an << endl;
      int tm;
      cin >> tm;
      if (binary_search(y.begin(), y.end(), tm)) {
        cout << "C" << ' ' << an << endl;
      } else {
        cout << "C" << ' ' << -1 << endl;
      }
    }
  }
}
