#include <bits/stdc++.h>
using namespace std;
template <class T, class R>
istream& operator>>(istream& in, pair<T, R>& p) {
  in >> p.first >> p.second;
  return in;
}
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& x : v) {
    in >> x;
  }
  return in;
}
const long long int mx = 210005;
vector<long long int> a, b, v;
vector<vector<long long int> > g;
long long int n, k1, k2;
long long int findClosest(const long long int& x) {
  v[x] = 1;
  if (a[x]) {
    return x;
  }
  for (const auto& nx : g[x]) {
    if (!v[nx]) {
      int vl;
      if ((vl = findClosest(nx)) != -1) {
        return vl;
      }
    }
  }
  return -1;
}
void read(long long int& x) {
  cin >> x;
  x--;
}
void print(const char& c, const long long int& x) {
  cout << c << " " << x + 1 << endl;
  cout.flush();
}
void testcase() {
  cin >> n;
  g.assign(n, vector<long long int>());
  a.assign(n, 0);
  b.assign(n, 0);
  v.assign(n, 0);
  for (long long int i = 0; i < (n - 1); i++) {
    long long int x, y;
    read(x);
    read(y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  cin >> k1;
  for (long long int i = 0; i < (k1); i++) {
    long long int x;
    read(x);
    a[x] = 1;
  }
  cin >> k2;
  long long int nd2, nd1;
  for (long long int i = 0; i < (k2); i++) {
    long long int x;
    read(x);
    b[x] = 1;
    nd2 = x;
  }
  print('B', nd2);
  read(nd1);
  nd1 = findClosest(nd1);
  print('A', nd1);
  read(nd2);
  if (b[nd2]) {
    print('C', nd1);
  } else {
    cout << "C -1\n";
    cout.flush();
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  long long int t;
  cin >> t;
  while (t--) {
    testcase();
  }
  return 0;
}
