#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  for (long long int x = 0; x < t; x++) {
    long long int n;
    cin >> n;
    vector<unordered_set<long long int>> e(n + 1);
    for (long long int i = 0; i < n - 1; i++) {
      long long int a, b;
      cin >> a >> b;
      e[a].insert(b);
      e[b].insert(a);
    }
    long long int k1;
    cin >> k1;
    vector<bool> marked(n + 1, false);
    for (long long int i = 0; i < k1; i++) {
      long long int xi;
      cin >> xi;
      marked[xi] = true;
    }
    long long int k2;
    cin >> k2;
    vector<long long int> marked2(k2);
    for (long long int i = 0; i < k2; i++) {
      cin >> marked2[i];
    }
    cout << "B " << marked2[0] << endl;
    long long int starting;
    cin >> starting;
    vector<bool> visited(n + 1, false);
    queue<long long int> q;
    q.push(starting);
    long long int matching = -1;
    while (((int)(q).size()) > 0) {
      long long int f = q.front();
      q.pop();
      if (visited[f]) {
        continue;
      }
      visited[f] = true;
      if (marked[f]) {
        matching = f;
        break;
      }
      for (auto n : e[f]) {
        q.push(n);
      }
    }
    cout << "A " << matching << endl;
    long long int z;
    cin >> z;
    if (find(marked2.begin(), marked2.end(), z) != marked2.end()) {
      cout << "C " << matching << endl;
    } else {
      cout << "C " << -1 << endl;
    }
  }
  return 0;
}
