#include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 61);
const int mod = (1e9 + 7);
const int MX = 1009;
int t, n, x, y, k1, k2, a[MX], b[MX], is[MX], is1[MX];
vector<int> v[MX];
int dfs(int x, int p) {
  if (is1[x]) return x;
  int mx = 0;
  for (auto pp : v[x]) {
    if (pp == p) continue;
    mx = max(mx, dfs(pp, x));
  }
  return mx;
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) v[i].clear(), is[i] = 0, is1[i] = 0;
    for (int i = 0; i < n - 1; i++) {
      scanf("%d%d", &x, &y);
      v[x].push_back(y);
      v[y].push_back(x);
    }
    cin >> k1;
    for (int i = 0; i < k1; i++) scanf("%d", &a[i]), is1[a[i]] = 1;
    cin >> k2;
    for (int i = 0; i < k2; i++) scanf("%d", &b[i]), is[b[i]] = 1;
    int ind;
    cout << "B " << b[k2 - 1] << endl;
    cin >> ind;
    int ans = dfs(ind, -1);
    cout << "A " << ans << endl;
    cin >> ind;
    cout << "C ";
    if (!is[ind])
      puts("-1");
    else
      cout << ans << endl;
  }
}
