#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
vector<int> g[maxn];
bool was[maxn];
int n;
set<int> s1, s2;
void Read() {
  s1.clear();
  s2.clear();
  for (int i = 0; i < maxn; ++i) g[i].clear(), was[i] = false;
  scanf("%d", &n);
  int a, b;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &a, &b);
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int k1, k2;
  scanf("%d", &k1);
  for (int i = 0; i < k1; ++i) {
    scanf("%d", &a);
    --a;
    s1.insert(a);
  }
  scanf("%d", &k2);
  for (int i = 0; i < k2; ++i) {
    scanf("%d", &a);
    --a;
    s2.insert(a);
  }
}
int dfs(int v) {
  if (s1.count(v)) return v;
  was[v] = true;
  int ans = -1;
  for (int j : g[v])
    if (!was[j]) ans = max(ans, dfs(j));
  return ans;
}
void calc() {
  int start = *s2.begin();
  cout << "B " << start + 1 << endl;
  cin >> start;
  start--;
  int v = dfs(start);
  cout << "A " << v + 1 << endl;
  int have;
  cin >> have;
  have--;
  if (s2.count(have))
    cout << "C " << v + 1 << endl;
  else
    cout << "C " << -1 << endl;
}
void alg() {
  Read();
  calc();
}
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; ++i) alg();
  return 0;
}
