#include <bits/stdc++.h>
using namespace std;
int dfs(int v, vector<vector<int> > &tree, vector<bool> &subtree,
        vector<bool> &visited) {
  visited[v] = true;
  if (subtree[v]) return v;
  for (int new_v : tree[v]) {
    if (!visited[new_v]) {
      int res = dfs(new_v, tree, subtree, visited);
      if (res != -1) {
        return res;
      }
    }
  }
  return -1;
}
int get_ancestor(int v, vector<vector<int> > &tree, vector<bool> &subtree) {
  vector<bool> visited(tree.size(), false);
  return dfs(v, tree, subtree, visited);
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int i_t = 0; i_t < t; ++i_t) {
    int n;
    cin >> n;
    vector<vector<int> > tree(n + 1);
    vector<bool> my_subtree(n + 1, false);
    vector<bool> chen_subtree(n + 1, false);
    for (int i = 1; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      tree[b].push_back(a);
      tree[a].push_back(b);
    }
    int k1, k2;
    cin >> k1;
    int input;
    for (int i = 0; i < k1; ++i) {
      cin >> input;
      my_subtree[input] = true;
    }
    cin >> k2;
    int last_chen_vertice;
    for (int i = 0; i < k2; ++i) {
      cin >> input;
      chen_subtree[input] = true;
      last_chen_vertice = input;
    }
    cout << "B " << last_chen_vertice << endl;
    int chen_vertice;
    cin >> chen_vertice;
    int ancestor = get_ancestor(chen_vertice, tree, my_subtree);
    if (ancestor == chen_vertice)
      cout << "C " << ancestor << endl;
    else {
      cout << "A " << ancestor << endl;
      int chen_ancestor;
      cin >> chen_ancestor;
      if (chen_subtree[chen_ancestor]) {
        cout << "C " << ancestor << endl;
      } else {
        cout << "C -1" << endl;
      }
    }
  }
  return 0;
}
