#include <bits/stdc++.h>
using namespace std;
long long DFS(long long source, vector<long long> ed[], long long v,
              unordered_map<long long, long long> m, long long prev) {
  if (m.find(source) != m.end()) {
    return source;
  }
  for (long long i = 0, _n = (ed[source].size()); i < _n; i++) {
    if (ed[source][i] != prev) {
      long long y = DFS(ed[source][i], ed, v, m, source);
      if (y != -1) return y;
    }
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> ed[n + 1];
    for (long long i = 0, _n = (n - 1); i < _n; i++) {
      long long a, b;
      cin >> a >> b;
      ed[a].push_back(b);
      ed[b].push_back(a);
    }
    long long k1;
    cin >> k1;
    unordered_map<long long, long long> m1;
    for (long long i = 0, _n = (k1); i < _n; i++) {
      long long x;
      cin >> x;
      m1[x]++;
    }
    long long k2;
    cin >> k2;
    unordered_map<long long, long long> m2;
    long long one = 0;
    for (long long i = 0, _n = (k2); i < _n; i++) {
      long long x;
      cin >> x;
      one = x;
      m2[x]++;
    }
    cout << "B " << one << endl;
    fflush(stdout);
    long long a;
    cin >> a;
    if (a == -1) {
      exit(0);
    }
    long long b = DFS(a, ed, n, m1, -1);
    cout << "A " << b << endl;
    fflush(stdout);
    long long c;
    cin >> c;
    if (c == -1) {
      exit(0);
    }
    if (m2.find(c) != m2.end()) {
      cout << "C " << b << endl;
    } else {
      cout << "C -1" << endl;
    }
    fflush(stdout);
  }
}
