#include <bits/stdc++.h>
using namespace std;
int n;
bool p1[2005], p2[2005], used[2005];
int x1[2005], x2[2005];
vector<vector<int>> g(1005);
int dfs(int v) {
  if (p1[v]) return v;
  used[v] = 1;
  for (int i = 0; i < g[v].size(); i++)
    if (!used[g[v][i]]) return dfs(g[v][i]);
  return -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i <= n; i++) {
      g[i].clear();
      p1[i] = 0;
      p2[i] = 0;
      used[i] = 0;
    }
    for (int i = 0; i < n - 1; i++) {
      int x, y;
      cin >> x >> y;
      g[x].push_back(y);
      g[y].push_back(x);
    }
    int k1, k2;
    cin >> k1;
    for (int i = 0; i < k1; i++) {
      cin >> x1[i];
      p1[x1[i]] = 1;
    }
    cin >> k2;
    for (int i = 0; i < k2; i++) {
      cin >> x2[i];
      p2[x2[i]] = 1;
    }
    cout << "B " << x2[0] << endl;
    int f;
    cin >> f;
    int ans = dfs(f);
    cout << "A " << ans << endl;
    int f1;
    cin >> f1;
    if (p2[f1])
      cout << "C " << ans << endl;
    else
      cout << "C -1" << endl;
  }
  return 0;
}
