Problem: You are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from 1 to n. Neither of you know the other's labelling of the tree.

You and Li Chen each chose a subtree (i.e., a connected subgraph) in that tree. Your subtree consists of the vertices labeled x_1, x_2, …, x_{k_1} in your labeling, Li Chen's subtree consists of the vertices labeled y_1, y_2, …, y_{k_2} in his labeling. The values of x_1, x_2, …, x_{k_1} and y_1, y_2, …, y_{k_2} are known to both of you.

<image> The picture shows two labelings of a possible tree: yours on the left and Li Chen's on the right. The selected trees are highlighted. There are two common nodes.

You want to determine whether your subtrees have at least one common vertex. Luckily, your friend Andrew knows both labelings of the tree. You can ask Andrew at most 5 questions, each of which is in one of the following two forms: 

  * A x: Andrew will look at vertex x in your labeling and tell you the number of this vertex in Li Chen's labeling. 
  * B y: Andrew will look at vertex y in Li Chen's labeling and tell you the number of this vertex in your labeling. 



Determine whether the two subtrees have at least one common vertex after asking some questions. If there is at least one common vertex, determine one of your labels for any of the common vertices.

Interaction

Each test consists of several test cases.

The first line of input contains a single integer t (1 ≤ t ≤ 100) — the number of test cases.

For each testcase, your program should interact in the following format.

The first line contains a single integer n (1 ≤ n ≤ 1 000) — the number of nodes in the tree.

Each of the next n-1 lines contains two integers a_i and b_i (1≤ a_i, b_i≤ n) — the edges of the tree, indicating an edge between node a_i and b_i according to your labeling of the nodes.

The next line contains a single integer k_1 (1 ≤ k_1 ≤ n) — the number of nodes in your subtree.

The next line contains k_1 distinct integers x_1,x_2,…,x_{k_1} (1 ≤ x_i ≤ n) — the indices of the nodes in your subtree, according to your labeling. It is guaranteed that these vertices form a subtree.

The next line contains a single integer k_2 (1 ≤ k_2 ≤ n) — the number of nodes in Li Chen's subtree.

The next line contains k_2 distinct integers y_1, y_2, …, y_{k_2} (1 ≤ y_i ≤ n) — the indices (according to Li Chen's labeling) of the nodes in Li Chen's subtree. It is guaranteed that these vertices form a subtree according to Li Chen's labelling of the tree's nodes.

Test cases will be provided one by one, so you must complete interacting with the previous test (i.e. by printing out a common node or -1 if there is not such node) to start receiving the next one.

You can ask the Andrew two different types of questions. 

  * You can print "A x" (1 ≤ x ≤ n). Andrew will look at vertex x in your labeling and respond to you with the number of this vertex in Li Chen's labeling. 
  * You can print "B y" (1 ≤ y ≤ n). Andrew will look at vertex y in Li Chen's labeling and respond to you with the number of this vertex in your labeling. 



You may only ask at most 5 questions per tree.

When you are ready to answer, print "C s", where s is your label of a vertex that is common to both subtrees, or -1, if no such vertex exists. Printing the answer does not count as a question. Remember to flush your answer to start receiving the next test case. 

After printing a question do not forget to print end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

  * fflush(stdout) or cout.flush() in C++; 
  * System.out.flush() in Java; 
  * flush(output) in Pascal; 
  * stdout.flush() in Python; 
  * see documentation for other languages. 



If the judge responds with -1, it means that you asked more queries than allowed, or asked an invalid query. Your program should immediately terminate (for example, by calling exit(0)). You will receive Wrong Answer; it means that you asked more queries than allowed, or asked an invalid query. If you ignore this, you can get other verdicts since your program will continue to read from a closed stream.

Hack Format

To hack, use the following format. Note that you can only hack with one test case.

The first line should contain a single integer t (t=1).

The second line should contain a single integer n (1 ≤ n ≤ 1 000).

The third line should contain n integers p_1, p_2, …, p_n (1≤ p_i≤ n) — a permutation of 1 to n. This encodes the labels that Li Chen chose for his tree. In particular, Li Chen chose label p_i for the node you labeled i.

Each of the next n-1 lines should contain two integers a_i and b_i (1≤ a_i, b_i≤ n). These edges should form a tree.

The next line should contain a single integer k_1 (1 ≤ k_1 ≤ n).

The next line should contain k_1 distinct integers x_1,x_2,…,x_{k_1} (1 ≤ x_i ≤ n). These vertices should form a subtree.

The next line should contain a single integer k_2 (1 ≤ k_2 ≤ n).

The next line should contain k_2 distinct integers y_1, y_2, …, y_{k_2} (1 ≤ y_i ≤ n). These vertices should form a subtree in Li Chen's tree according to the permutation above.

Examples

Input

1
3
1 2
2 3
1
1
1
2
2
1


Output

A 1
B 2
C 1


Input

2
6
1 2
1 3
1 4
4 5
4 6
4
1 3 4 5
3
3 5 2
3
6
1 2
1 3
1 4
4 5
4 6
3
1 2 3
3
4 1 6
5


Output

B 2
C 1
A 1
C -1

Note

For the first sample, Li Chen's hidden permutation is [2, 3, 1], and for the second, his hidden permutation is [5, 3, 2, 4, 1, 6] for both cases.

In the first sample, there is a tree with three nodes in a line. On the top, is how you labeled the tree and the subtree you chose, and the bottom is how Li Chen labeled the tree and the subtree he chose: 

<image>

In the first question, you ask Andrew to look at node 1 in your labelling and tell you the label of it in Li Chen's labelling. Andrew responds with 2. At this point, you know that both of your subtrees contain the same node (i.e. node 1 according to your labeling), so you can output "C 1" and finish. However, you can also ask Andrew to look at node 2 in Li Chen's labelling and tell you the label of it in your labelling. Andrew responds with 1 (this step was given with the only reason — to show you how to ask questions).

For the second sample, there are two test cases. The first looks is the one from the statement: 

<image>

We first ask "B 2", and Andrew will tell us 3. In this case, we know 3 is a common vertex, and moreover, any subtree with size 3 that contains node 3 must contain node 1 as well, so we can output either "C 1" or "C 3" as our answer.

In the second case in the second sample, the situation looks as follows: 

<image>

In this case, you know that the only subtree of size 3 that doesn't contain node 1 is subtree 4,5,6. You ask Andrew for the label of node 1 in Li Chen's labelling and Andrew says 5. In this case, you know that Li Chen's subtree doesn't contain node 1, so his subtree must be consist of the nodes 4,5,6 (in your labelling), thus the two subtrees have no common nodes.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
struct LCA {
  const int lg = 12;
  const int sz = 1 << lg;
  const int ms = sz - 1;
  int n;
  vector<int> P, D, E, A, B, T, ht;
  vector<vector<int> > G, dat;
  LCA(int n)
      : n(n),
        P(n, -1),
        D(n),
        E(n * 2, 0),
        A(n * 2, -1),
        B(n * 2 / lg + 1),
        T(sz, 0),
        G(n) {}
  void add_edge(int u, int v) {
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  void dfs(int v, int p, int d, int &k) {
    D[v] = k;
    A[k] = P[v] = p;
    E[k++] = d;
    for (int u : G[v])
      if (u != p) dfs(u, v, d + 1, k);
    A[k] = P[v];
    E[k++] = d - 1;
  }
  inline int comp(int i, int j) { return E[i] < E[j] ? i : j; };
  inline int comp(int i, int j, int k) { return comp(comp(i, j), k); };
  void build(int r = 0) {
    int k = 0;
    dfs(r, -1, 1, k);
    B[0] = 1;
    for (int i = 1; i < n * 2; i++) B[i / lg] |= (E[i - 1] < E[i]) << (i % lg);
    for (int b = 0; b < sz; b++) {
      int e = 0, w = 1, &x = T[b];
      for (int i = 0; i < lg; i++) {
        if ((b >> i) & 1)
          e++;
        else
          e--;
        if (e < w) e = w, x = i;
      }
    }
    int m = (n * 2 + lg - 1) / lg;
    int h = 1;
    while ((1 << h) < m) h++;
    dat.assign(h, vector<int>(m, -1));
    ht.assign(m + 1, 0);
    for (int j = 2; j <= m; j++) ht[j] = ht[j >> 1] + 1;
    for (int j = 0; j < n * 2; j++) {
      if (dat[0][j / lg] < 0) dat[0][j / lg] = j;
      dat[0][j / lg] = comp(dat[0][j / lg], j);
    }
    for (int i = 1, p = 1; i < h; i++, p <<= 1)
      for (int j = 0; j < m; j++)
        dat[i][j] = comp(dat[i - 1][j], dat[i - 1][min(j + p, m - 1)]);
  }
  inline int cs(int a, int b) {
    int l = b - a;
    return comp(dat[ht[l]][a], dat[ht[l]][b - (1 << ht[l])]);
  }
  inline int es(int i, int l, int r) {
    int x = r - i * lg + 1, y = l - i * lg;
    int b = (((B[i] | (ms << x)) >> y) | (ms << (lg - y))) & ms;
    return l + T[b];
  }
  inline int ls(int i, int l) {
    int k = l - i * lg;
    int b = ((B[i] >> k) | (ms << (lg - k))) & ms;
    return l + T[b];
  }
  inline int rs(int j, int r) {
    int k = r - j * lg + 1;
    int b = (B[j] | (ms << k)) & ms;
    return j * lg + T[b];
  }
  inline int rmq(int l, int r) {
    int i = l / lg, j = r / lg;
    if (i == j) return es(i, l, r);
    if (i + 1 == j) return comp(ls(i, l), rs(j, r));
    return comp(ls(i, l), cs(i + 1, j), rs(j, r));
  }
  int lca(int l, int r) {
    if (l == r) return l;
    if (D[l] > D[r]) swap(l, r);
    int x = D[l], y = D[r];
    int m = rmq(x, y);
    return m == x ? l : A[m];
  }
};
void askmine(int x) {
  x++;
  cout << "A " << x << endl;
}
void askyours(int y) {
  y++;
  cout << "B " << y << endl;
}
void ans(int s) {
  if (s != -1) {
    s++;
  }
  cout << "C " << s << endl;
}
int get() {
  int k;
  cin >> k;
  k--;
  return k;
}
void solve() {
  int n;
  cin >> n;
  vvi adj(n);
  LCA lca(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    lca.add_edge(a, b);
  }
  lca.build();
  vi ds(n);
  function<void(int, int)> dfs = [&](int v, int p) {
    if (p == -1) {
      ds[v] = 0;
    } else {
      ds[v] = ds[p] + 1;
    }
    for (int s : adj[v]) {
      if (s != p) {
        dfs(s, v);
      }
    }
  };
  dfs(0, -1);
  int k1;
  cin >> k1;
  set<int> mine;
  int depth = 1e9, par;
  for (int i = 0; i < k1; i++) {
    int r;
    cin >> r;
    r--;
    mine.insert(r);
    if (ds[r] < depth) {
      depth = ds[r];
      par = r;
    }
  }
  int k2;
  cin >> k2;
  set<int> yours;
  for (int i = 0; i < k2; i++) {
    int r;
    cin >> r;
    r--;
    yours.insert(r);
  }
  askmine(par);
  int r = get();
  if (yours.count(r)) {
    ans(par);
    return;
  }
  askyours(*yours.begin());
  r = get();
  if (mine.count(r)) {
    ans(r);
    return;
  }
  int ok = 0, oks;
  for (int s : adj[par]) {
    if (mine.count(s)) {
      if (lca.lca(s, r) == s) {
        assert(ok == 0);
        ok = 1;
        oks = s;
      }
    }
  }
  if (!ok) {
    ans(-1);
    return;
  }
  int kek = -1;
  for (int k : mine) {
    if (lca.lca(oks, k) == oks && lca.lca(r, k) == k) {
      if (kek == -1) {
        kek = k;
      } else {
        if (ds[k] > ds[kek]) {
          kek = k;
        }
      }
    }
  }
  assert(kek != -1);
  askmine(kek);
  r = get();
  if (yours.count(r)) {
    ans(kek);
  } else {
    ans(-1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(10);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}