#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1100];
int need[1100];
bool visit[1100];
vector<pair<int, int> > vec;
int exist[1100];
void bfs(int st) {
  queue<pair<int, int> > q;
  memset(visit, 0, sizeof visit);
  q.push({st, 0});
  while (!q.empty()) {
    int u = q.front().first;
    int c = q.front().second;
    q.pop();
    if (visit[u]) continue;
    visit[u] = 1;
    if (need[u]) vec.push_back({c, u});
    for (auto v : adj[u])
      if (!visit[v]) q.push({v, c + 1});
  }
  sort(vec.begin(), vec.end());
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) adj[i].clear();
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      scanf("%d%d", &a, &b);
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    int k;
    scanf("%d", &k);
    memset(need, 0, sizeof need);
    for (int i = 0; i < k; ++i) {
      int x;
      scanf("%d", &x);
      need[x] = 1;
    }
    scanf("%d", &k);
    memset(exist, 0, sizeof exist);
    int y;
    for (int i = 0; i < k; ++i) {
      scanf("%d", &y);
      exist[y] = 1;
    }
    vec.clear();
    cout << "B " << y << endl;
    int st;
    cin >> st;
    bfs(st);
    cout << "A " << vec[0].second << endl;
    cin >> y;
    if (exist[y])
      cout << "C " << vec[0].second << endl;
    else
      cout << "C -1" << endl;
  }
  return 0;
}
