#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
void yes() {
  cout << "Yes"
       << "\n";
}
void no() {
  cout << "No"
       << "\n";
}
struct Sync_stdio {
  Sync_stdio() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
  }
} _sync_stdio;
struct FAIL {
  FAIL() {
    cout << "CHANGE!!!"
         << "\n";
  }
};
vector<vector<int>> g;
vector<int> cl;
vector<int> used;
vector<int> a;
vector<int> b;
void dfs(int x, int best = -1) {
  used[x] = 1;
  if (binary_search(a.begin(), a.end(), x)) {
    best = x;
  }
  cl[x] = best;
  for (auto y : g[x]) {
    if (used[y]) {
      continue;
    }
    dfs(y, best);
  }
}
void solve() {
  g.clear();
  cl.clear();
  used.clear();
  int n;
  cin >> n;
  g.resize(n);
  cl.resize(n);
  used.resize(n);
  for (int i = (0); i < (n - 1); ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int m1;
  cin >> m1;
  a.resize(m1);
  for (int __i = 0; __i < (m1); ++__i) cin >> a[__i];
  ;
  sort(a.begin(), a.end());
  for (auto& elem : a) {
    --elem;
  }
  int m2;
  cin >> m2;
  b.resize(m2);
  for (int __i = 0; __i < (m2); ++__i) cin >> b[__i];
  ;
  sort(b.begin(), b.end());
  for (auto& elem : b) {
    --elem;
  }
  dfs(a[0]);
  cout << "B " << b[0] + 1 << "\n";
  cout.flush();
  int value;
  cin >> value;
  --value;
  if (binary_search(a.begin(), a.end(), value)) {
    cout << "C " << value + 1 << "\n";
    cout.flush();
    return;
  }
  cout << "A " << cl[value] + 1 << "\n";
  cout.flush();
  int value2;
  cin >> value2;
  --value2;
  if (binary_search(b.begin(), b.end(), value2)) {
    cout << "C " << cl[value] + 1 << "\n";
    cout.flush();
    return;
  }
  cout << "C " << -1 << "\n";
  cout.flush();
}
int main() {
  int n;
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    solve();
  }
}
