#include <bits/stdc++.h>
const int32_t MAX_N = 1000;
bool isInA[MAX_N + 5], isInB[MAX_N + 5], isVisited[MAX_N + 5];
std::vector<int32_t> v[MAX_N + 5];
int32_t Dfs(int32_t nd) {
  isVisited[nd] = true;
  if (isInA[nd]) {
    return nd;
  }
  int32_t ans = INT32_MAX;
  for (auto &x : v[nd]) {
    if (!isVisited[x]) {
      ans = std::min(ans, Dfs(x));
    }
  }
  return ans;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int32_t cntTests;
  std::cin >> cntTests;
  for (int32_t cs = 1; cs <= cntTests; cs++) {
    int32_t n;
    std::cin >> n;
    for (int32_t i = 1; i <= n; i++) {
      v[i].clear();
    }
    for (int32_t i = 0; i < n - 1; i++) {
      int32_t a, b;
      std::cin >> a >> b;
      v[a].push_back(b);
      v[b].push_back(a);
    }
    memset(isInA, 0, sizeof(isInA));
    memset(isInB, 0, sizeof(isInB));
    int32_t k1;
    std::cin >> k1;
    std::vector<int32_t> v1(k1);
    for (int32_t i = 0; i < k1; i++) {
      std::cin >> v1[i];
      isInA[v1[i]] = true;
    }
    int32_t k2;
    std::cin >> k2;
    std::vector<int32_t> v2(k2);
    for (int32_t i = 0; i < k2; i++) {
      std::cin >> v2[i];
      isInB[v2[i]] = true;
    }
    std::cout << "B " << v2[0] << '\n' << std::flush;
    int32_t stNode;
    std::cin >> stNode;
    memset(isVisited, 0, sizeof(isVisited));
    int32_t target = Dfs(stNode);
    std::cout << "A " << target << '\n' << std::flush;
    int32_t res;
    std::cin >> res;
    if (isInB[res]) {
      std::cout << "C " << target << '\n' << std::flush;
    } else {
      std::cout << "C " << -1 << '\n' << std::flush;
    }
  }
}
