#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);
template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (auto vv : v) os << vv << ",";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, set<T> v) {
  os << "[";
  for (auto vv : v) os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <typename T>
inline T sq(T a) {
  return a * a;
}
template <typename T>
T gcd(T a, T b) {
  if (a < b) return gcd(b, a);
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T, typename U>
T mypow(T b, U n) {
  if (n == 0) return 1;
  if (n == 1) return b;
  if (n % 2 == 0) {
    return mypow(b * b, n / 2);
  } else {
    return mypow(b, n - 1) * b;
  }
}
ll pcnt(ll b) { return __builtin_popcountll(b); }
template <typename T>
T iceil(T n, T d) {
  return (n + d - 1) / d;
}
int query(int t, int v) {
  cout << "AB"[t] << " " << v + 1 << endl;
  int res;
  cin >> res;
  return res - 1;
}
void answer(int v) { cout << 'C' << " " << (v < 0 ? -1 : v + 1) << endl; }
int main() {
  int Q;
  cin >> Q;
  for (int q = 0; q < Q; ++q) {
    int n;
    cin >> n;
    vector<int> path[n];
    for (int i = 0; i < n - 1; ++i) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      path[u].push_back(v);
      path[v].push_back(u);
    }
    int k[2];
    set<int> x[2];
    for (int i = 0; i < 2; ++i) {
      cin >> k[i];
      for (int j = 0; j < k[i]; ++j) {
        int v;
        cin >> v;
        --v;
        x[i].insert(v);
      }
    }
    int r = query(1, *x[1].begin());
    if (x[0].count(r) == 1) {
      answer(r);
      continue;
    }
    bool visited[n];
    fill(visited, visited + n, false);
    visited[r] = true;
    queue<int> que;
    que.push(r);
    while (!que.empty()) {
      int v = que.front();
      que.pop();
      if (x[0].count(v)) {
        r = v;
        break;
      }
      for (int sv : path[v]) {
        if (visited[sv]) continue;
        visited[sv] = true;
        que.push(sv);
      }
    }
    int s = query(0, r);
    if (x[1].count(s) == 1) {
      answer(r);
    } else {
      answer(-1);
    }
  }
  return 0;
}
