#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v[1010];
int fa[1010];
int a[1010], b[1010];
int c[1010];
int d[1010];
int tot1, tot2;
void dfs(int x, int f) {
  for (int i = 0; i < v[x].size(); i++) {
    int k = v[x][i];
    if (k == f) continue;
    fa[k] = x;
    dfs(k, x);
  }
}
signed main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) fa[i] = i, v[i].clear(), c[i] = 0, d[i] = 0;
    for (int i = 1; i < n; i++) {
      int l, r;
      scanf("%d%d", &l, &r);
      v[l].push_back(r);
      v[r].push_back(l);
    }
    tot1 = 0, tot2 = 0;
    scanf("%d", &tot1);
    for (int i = 1; i <= tot1; i++) scanf("%d", &a[i]), c[a[i]] = 1;
    scanf("%d", &tot2);
    for (int i = 1; i <= tot2; i++) scanf("%d", &b[i]), d[b[i]] = 1;
    dfs(a[1], 0);
    cout << "A " << a[1] << endl;
    cout.flush();
    int k;
    scanf("%d", &k);
    if (d[k]) {
      cout << "C " << a[1] << endl;
      cout.flush();
      continue;
    }
    cout << "B " << b[1] << endl;
    cout.flush();
    int w;
    scanf("%d", &w);
    if (c[w]) {
      cout << "C " << w << endl;
      cout.flush();
      continue;
    }
    while (1) {
      w = fa[w];
      if (c[w]) break;
    }
    cout << "A " << w << endl;
    cout.flush();
    scanf("%d", &k);
    if (d[k]) {
      cout << "C " << w << endl;
      cout.flush();
      continue;
    }
    cout << "C " << -1 << endl;
    cout.flush();
  }
  return 0;
}
