#include <bits/stdc++.h>
using namespace std;
vector<int> tree[1010];
bool vis[1010];
bool kk1[1010];
bool kk2[1010];
vector<int> vk1;
vector<int> vk2;
int k1, k2;
int main() {
  int t;
  cin >> t;
  while (t--) {
    for (int i = 0; i < 1010; i++) tree[i].clear();
    memset(kk1, 0, sizeof kk1);
    memset(kk2, 0, sizeof kk2);
    memset(vis, 0, sizeof vis);
    vk1.clear();
    vk2.clear();
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      cin >> a >> b;
      tree[a].push_back(b);
      tree[b].push_back(a);
    }
    cin >> k1;
    for (int i = 0; i < k1; i++) {
      int x;
      cin >> x;
      kk1[x] = true;
      vk1.push_back(x);
    }
    cin >> k2;
    for (int i = 0; i < k2; i++) {
      int x;
      cin >> x;
      kk2[x] = true;
      vk2.push_back(x);
    }
    cout << "B " << vk2[0] << endl;
    cout.flush();
    int start;
    cin >> start;
    int end = -1;
    queue<int> bfs;
    vis[start] = true;
    bfs.push(start);
    while (!bfs.empty() && end == -1) {
      int nxt = bfs.front();
      bfs.pop();
      if (kk1[nxt]) {
        end = nxt;
        break;
      }
      for (int i = 0; i < tree[nxt].size(); i++) {
        int vtx = tree[nxt][i];
        if (vis[vtx]) continue;
        if (kk1[vtx]) {
          end = vtx;
          break;
        }
        vis[vtx] = true;
        bfs.push(vtx);
      }
    }
    cout << "A " << end << endl;
    cout.flush();
    int show;
    cin >> show;
    if (kk2[show]) {
      cout << "C " << end << endl;
    } else {
      cout << "C " << -1 << endl;
    }
    cout.flush();
  }
  return 0;
}
