#include <bits/stdc++.h>
using namespace std;
vector<int> graph[1010];
int A[1010], B[1010], mk1[1010], mk2[1010], visited[1010];
int cl = -1;
void dfs(int s) {
  visited[s] = 1;
  if (cl == -1 && mk1[s]) cl = s;
  for (int i = 0; i < graph[s].size(); i++)
    if (!visited[graph[s][i]]) dfs(graph[s][i]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    memset(mk1, 0, sizeof(mk1));
    memset(mk2, 0, sizeof(mk2));
    memset(visited, 0, sizeof(visited));
    for (int i = 0; i < n; i++) graph[i].clear();
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      cin >> a >> b;
      graph[a - 1].push_back(b - 1);
      graph[b - 1].push_back(a - 1);
    }
    int k1;
    cin >> k1;
    for (int i = 0; i < k1; i++) {
      cin >> A[i];
      mk1[A[i] - 1] = 1;
    }
    int k2;
    cin >> k2;
    for (int i = 0; i < k2; i++) cin >> B[i], mk2[B[i] - 1] = 1;
    cout << "B " << B[0] << endl;
    int x;
    cin >> x;
    x--;
    if (mk1[x]) {
      cout << "C " << x + 1 << endl;
    } else {
      cl = -1;
      dfs(x);
      cout << "A " << cl + 1 << endl;
      int y;
      cin >> y;
      y--;
      if (mk2[y])
        cout << "C " << cl + 1 << endl;
      else
        cout << "C -1" << endl;
    }
  }
}
