#include <bits/stdc++.h>
using namespace std;
std::ifstream get_file_input() {
  std::ifstream ifs;
  ifs.open("input.txt");
  std::ios_base::sync_with_stdio(false);
  ifs.tie(nullptr);
  return ifs;
}
std::istream& get_standard_input() {
  std::istream& input = std::cin;
  std::ios_base::sync_with_stdio(false);
  input.tie(nullptr);
  return input;
}
struct vertice {
  vector<int> childs;
  int parent;
  bool is_in_my;
};
vector<vertice> vertices;
vector<vector<int>> edges;
vector<int> xes;
vector<int> yes;
int n;
void build_tree(int now, int parent) {
  for (auto next : edges[now]) {
    if (next != parent) {
      build_tree(next, now);
      vertices[now].childs.push_back(next);
    }
  }
  vertices[now].parent = parent;
}
int prepare(std::istream& input) {
  input >> n;
  edges = vector<vector<int>>(n);
  vertices = vector<vertice>(n);
  for (int i = 0; i < n; ++i) {
    vertices[i].is_in_my = false;
  }
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    input >> a >> b;
    --a;
    --b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  int k1;
  xes = vector<int>(0);
  input >> k1;
  for (int i = 0; i < k1; ++i) {
    int x;
    input >> x;
    --x;
    vertices[x].is_in_my = true;
    xes.push_back(x);
  }
  int k2;
  yes = vector<int>(0);
  input >> k2;
  for (int i = 0; i < k2; ++i) {
    int y;
    input >> y;
    --y;
    yes.push_back(y);
  }
  int root = xes[0];
  build_tree(root, -1);
  return root;
}
int request_B(std::istream& input, int y) {
  cout << "B " << y + 1 << '\n';
  cout.flush();
  int my_numeration;
  input >> my_numeration;
  --my_numeration;
  return my_numeration;
}
int request_A(std::istream& input, int x) {
  cout << "A " << x + 1 << '\n';
  cout.flush();
  int his_numeration;
  input >> his_numeration;
  --his_numeration;
  return his_numeration;
}
int up_until_good(int num) {
  if (vertices[num].is_in_my) {
    return true;
  }
  return up_until_good(vertices[num].parent);
}
vector<int> rollout_up(int num) {
  if (num == -1) {
    return vector<int>(0);
  }
  auto ans = rollout_up(vertices[num].parent);
  ans.push_back(num);
  return ans;
}
int get_common_parent(int first, int second) {
  auto first_rollout = rollout_up(first);
  auto second_rollout = rollout_up(second);
  int min = std::min(first_rollout.size(), second_rollout.size());
  int ans = first_rollout[0];
  for (int i = 0; i < min; ++i) {
    if (first_rollout[i] == second_rollout[i]) {
      ans = first_rollout[i];
    }
  }
  return ans;
}
int main() {
  std::istream& input = get_standard_input();
  int t;
  input >> t;
  for (int test_num = 0; test_num < t; ++test_num) {
    int root = prepare(input);
    int k1 = xes.size();
    int k2 = yes.size();
    if (k2 == 1) {
      int my_numeration_0 = request_B(input, yes[0]);
      bool good = false;
      for (int i = 0; i < xes.size(); ++i) {
        if (xes[i] == my_numeration_0) {
          cout << "C " << xes[i] + 1 << '\n';
          cout.flush();
          good = true;
          break;
        }
      }
      if (good == false) {
        cout << "C " << -1 << '\n';
        cout.flush();
      }
      continue;
    }
    int first = request_B(input, yes[0]);
    int second = request_B(input, yes[1]);
    bool good = false;
    int common_parent = get_common_parent(first, second);
    for (int i = 0; i < xes.size(); ++i) {
      if (xes[i] == common_parent) {
        cout << "C " << xes[i] + 1 << '\n';
        cout.flush();
        good = true;
        break;
      }
    }
    if (good) {
      continue;
    }
    good = false;
    int first_good = up_until_good(common_parent);
    int his_numeration = request_A(input, first_good);
    for (int i = 0; i < yes.size(); ++i) {
      if (yes[i] == his_numeration) {
        cout << "C " << first_good + 1 << '\n';
        cout.flush();
        good = true;
        break;
      }
    }
    if (good == false) {
      cout << "C " << -1 << '\n';
      cout.flush();
    }
  }
}
