Meanwhile, the kingdom of K is getting ready for the marriage of the King's daughter. However, in order not to lose face in front of the relatives, the King should first finish reforms in his kingdom. As the King can not wait for his daughter's marriage, reforms must be finished as soon as possible.

The kingdom currently consists of n cities. Cities are connected by n - 1 bidirectional road, such that one can get from any city to any other city. As the King had to save a lot, there is only one path between any two cities.

What is the point of the reform? The key ministries of the state should be relocated to distinct cities (we call such cities important). However, due to the fact that there is a high risk of an attack by barbarians it must be done carefully. The King has made several plans, each of which is described by a set of important cities, and now wonders what is the best plan.

Barbarians can capture some of the cities that are not important (the important ones will have enough protection for sure), after that the captured city becomes impassable. In particular, an interesting feature of the plan is the minimum number of cities that the barbarians need to capture in order to make all the important cities isolated, that is, from all important cities it would be impossible to reach any other important city.

Help the King to calculate this characteristic for each of his plan.

Input

The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cities in the kingdom.

Each of the next n - 1 lines contains two distinct integers ui, vi (1 ≤ ui, vi ≤ n) — the indices of the cities connected by the i-th road. It is guaranteed that you can get from any city to any other one moving only along the existing roads.

The next line contains a single integer q (1 ≤ q ≤ 100 000) — the number of King's plans.

Each of the next q lines looks as follows: first goes number ki — the number of important cities in the King's plan, (1 ≤ ki ≤ n), then follow exactly ki space-separated pairwise distinct numbers from 1 to n — the numbers of important cities in this plan.

The sum of all ki's does't exceed 100 000.

Output

For each plan print a single integer — the minimum number of cities that the barbarians need to capture, or print  - 1 if all the barbarians' attempts to isolate important cities will not be effective.

Examples

Input

4
1 3
2 3
4 3
4
2 1 2
3 2 3 4
3 1 2 4
4 1 2 3 4


Output

1
-1
1
-1


Input

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


Output

2

Note

In the first sample, in the first and the third King's plan barbarians can capture the city 3, and that will be enough. In the second and the fourth plans all their attempts will not be effective.

In the second sample the cities to capture are 3 and 5.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AlexFetisov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD_399 solver = new TaskD_399();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD_399 {
        Graph tree;
        private int[][] pp;
        private FenwickTreeSum ft;
        private DFSOrder order;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            tree = new Graph();
            tree.initGraph(n, n - 1);
            for (int i = 0; i < n - 1; ++i) {
                tree.addEdge(in.nextInt() - 1, in.nextInt() - 1);
            }
            int[] parent = Parent.run(tree, 0);
            pp = Parent.getLevelParents(tree, 0);
            order = new DFSOrder(tree, 0, parent);
            LCA LC = new LCA(tree, 0, parent);
            final int[] vertexLevels = Parent.getVertexLevels(tree, 0, parent);
            int countQueries = in.nextInt();
            ft = new FenwickTreeSum(2 * n);
            boolean[] isGood = new boolean[n];
            boolean[] wasDeleted = new boolean[n];
            List<Integer> memoDeleted = new ArrayList<Integer>();

            while (countQueries-- > 0) {
                int res = 0;
                int am = in.nextInt();
                Integer[] cities = new Integer[am];
                for (int i = 0; i < am; ++i) {
                    cities[i] = in.nextInt() - 1;
                    isGood[cities[i]] = true;
                    ft.update(order.start(cities[i]), 1);
                }
                memoDeleted.clear();

                Arrays.sort(cities, new Comparator<Integer>() {

                    public int compare(Integer o1, Integer o2) {
                        return order.start(o1) - order.start(o2);
                    }
                });

                boolean done = false;
                for (int v : cities) {
                    if (parent[v] != -1 && isGood[parent[v]]) {
                        out.println(-1);
                        done = true;
                        break;
                    }
                }

                if (!done) {
                    TreeSet<Integer> allLCA = new TreeSet<Integer>();
                    allLCA.add(cities[0]);
                    for (int i = 1; i < am; ++i) {
                        allLCA.add(LC.LCA(cities[i - 1], cities[i]));
                        allLCA.add(cities[i]);
                    }

                    Integer[] lcas = new Integer[allLCA.size()];
                    int cnt = 0;
                    for (int i : allLCA) {
                        lcas[cnt++] = i;
                    }
                    Arrays.sort(lcas, new Comparator<Integer>() {

                        public int compare(Integer o1, Integer o2) {
                            return vertexLevels[o2] - vertexLevels[o1];
                        }
                    });

                    TreeSet<Item> dict = new TreeSet<Item>();
                    for (int i = 0; i < am; ++i) {
                        dict.add(new Item(order.start(cities[i]), cities[i]));
                    }

                    for (int x : lcas) {
                        if (isGood[x]) {
                            while (true) {
                                Item it = dict.higher(new Item(order.start(x), x));
                                if (it == null) break;
                                if (order.isChild(it.v, x)) {
                                    ++res;
                                    ft.update(it.pos, -1);
                                    dict.remove(it);
                                } else {
                                    break;
                                }
                            }
                        } else {
                            int count = 0;
                            int memo = -1;
                            while (true) {
                                Item it = dict.higher(new Item(order.start(x), x));
                                if (it == null) break;
                                if (order.isChild(it.v, x)) {
                                    ft.update(it.pos, -1);
                                    dict.remove(it);
                                    ++count;
                                    memo = it.v;
                                } else {
                                    break;
                                }
                            }

                            if (count > 1) {
                                ++res;
                            } else {
                                if (count == 1) {
                                    dict.add(new Item(order.start(memo), memo));
                                }
                            }
                        }
                    }
                    out.println(res);

                }


                // Clean up
                for (int i = 0; i < am; ++i) {
//                ft.update(order.start(cities[i]), -1);
                    isGood[cities[i]] = false;
                }
                for (int v : memoDeleted) {
                    wasDeleted[v] = false;
                }
            }
        }

        class Item implements Comparable<Item> {
            int pos;
            int v;

            public Item(int pos, int v) {
                this.pos = pos;
                this.v = v;
            }


            public int compareTo(Item o) {
                return pos - o.pos;
            }

        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String nextString() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }

    static class ArrayUtils {
        public static void fill(int[][] f, int value) {
            for (int i = 0; i < f.length; ++i) {
                Arrays.fill(f[i], value);
            }
        }

        public static void fill(int[][][] a, int value) {
            for (int i = 0; i < a.length; ++i) {
                fill(a[i], value);
            }
        }

    }

    static class Graph {
        public int[] from;
        public int[] to;
        public int[] first;
        public int[] next;
        public int nVertex;
        public int nEdges;
        public int curEdge;

        public Graph() {
        }

        public void initGraph(int n, int m) {
            curEdge = 0;
            nVertex = n;
            nEdges = m;
            from = new int[m * 2];
            to = new int[m * 2];
            first = new int[n];
            next = new int[m * 2];
            Arrays.fill(first, -1);
        }

        public void addEdge(int a, int b) {
            next[curEdge] = first[a];
            first[a] = curEdge;
            to[curEdge] = b;
            from[curEdge] = a;
            ++curEdge;

            next[curEdge] = first[b];
            first[b] = curEdge;
            to[curEdge] = a;
            from[curEdge] = b;
            ++curEdge;
        }

    }

    static class DFSOrder {
        int[] start;
        int[] end;

        public DFSOrder(Graph tree, int root, int[] p) {
            start = new int[tree.nVertex];
            end = new int[tree.nVertex];
            buildDfsOrder(tree, root, p);
        }

        public boolean isChild(int candidate, int v) {
            return start[v] <= start[candidate] && end[v] >= end[candidate];
        }

        public int start(int v) {
            return start[v];
        }

        private void buildDfsOrder(Graph tree, int root, int[] p) {
            int[] stack = new int[2 * tree.nVertex];
            int top = 0;
            stack[top++] = (root + 1);
            int time = 0;
            while (top > 0) {
                --top;
                int v = stack[top];
                if (v < 0) {
                    v = (-v) - 1;
                    end[v] = time;
                    ++time;
                } else {
                    --v;
                    start[v] = time++;
                    stack[top++] = -(v + 1);
                    for (int i = tree.first[v]; i != -1; i = tree.next[i]) {
                        if (p[v] != tree.to[i]) {
                            stack[top++] = (tree.to[i] + 1);
                        }
                    }
                }
            }
        }

    }

    static class LCA {
        public int[] height;
        public int[] dfsOrder;
        public int[] posInDfsOrder;
        public int countDfsOrder;
        private int block;
        private int[][] blockTable;
        int logMaxList;
        int[] blockHash;
        int[][][] blockRmq;
        int[] log2;
        int[] parent;
        int n;

        public LCA(Graph tree, int root, int[] parent) {
            n = tree.nVertex;
            log2 = new int[2 * n];
            height = new int[n];
            Arrays.fill(height, -1);
            dfsOrder = new int[n * 2 - 1];
            posInDfsOrder = new int[n];
            countDfsOrder = 0;
            this.parent = parent;
            dfsStack(tree, root);
            logMaxList = log(countDfsOrder);
            buildLCA();
        }

        private void dfsStack(Graph tree, int v) {
            int[] stackVertex = new int[tree.nVertex * 2];
            int[] stackHeight = new int[tree.nVertex * 2];
            int[] stackEdge = new int[tree.nVertex * 2];
            int top = 0;
            stackHeight[top] = 0;
            stackVertex[top] = v;
            stackEdge[top] = tree.first[v];
            ++top;
            int currentHeight, edge;
            while (top > 0) {
                --top;
                v = stackVertex[top];
                currentHeight = stackHeight[top];
                edge = stackEdge[top];

                if (height[v] == -1) {
                    height[v] = currentHeight;
                    posInDfsOrder[v] = countDfsOrder;
                    dfsOrder[countDfsOrder++] = v;
                } else {
                    dfsOrder[countDfsOrder++] = v;
                }

                if (edge == -1) continue;

                int nextEdge = tree.next[edge];

                if (nextEdge != -1) {
                    if (tree.to[nextEdge] == parent[v]) {
                        nextEdge = tree.next[nextEdge];
                    }
                }

                stackHeight[top] = currentHeight;
                stackVertex[top] = v;
                stackEdge[top] = nextEdge;
                ++top;

                int u = tree.to[edge];
                stackHeight[top] = currentHeight + 1;
                stackVertex[top] = u;
                int edgeId = tree.first[u];
                if (edgeId != -1) {
                    if (tree.to[edgeId] == v) {
                        edgeId = tree.next[edgeId];
                    }
                }
                stackEdge[top] = edgeId;
                ++top;
            }
        }

        int log(int n) {
            int res = 1;
            while ((1 << res) < n) ++res;
            return res;
        }

        int minHeight(int i, int j) {
            return height[dfsOrder[i]] < height[dfsOrder[j]] ? i : j;
        }

        void buildLCA() {
            block = (logMaxList + 1) / 2;
            int blocks = countDfsOrder / block + ((countDfsOrder % block > 0) ? 1 : 0);
            int maxBlocks = ((2 * n) / block) + 2;
            blockHash = new int[maxBlocks + 1];
            blockTable = new int[maxBlocks + 1][logMaxList + 1];
            blockRmq = new int[(int) (Math.sqrt(2 * n) + 2)][block + 2][block + 2];
            ArrayUtils.fill(blockRmq, -1);
            ArrayUtils.fill(blockTable, -1);
            Arrays.fill(blockHash, 0);

            // precalc in each block and build sparse table
            for (int i = 0, blockId = 0, j = 0; i < countDfsOrder; ++i, ++j) {
                if (j == block) {
                    j = 0;
                    ++blockId;
                }
                if (blockTable[blockId][0] == -1 || minHeight(i, blockTable[blockId][0]) == i) {
                    blockTable[blockId][0] = i;
                }
            }

            for (int j = 1; j <= logMaxList; ++j) {
                for (int i = 0; i < blocks; ++i) {
                    int ni = i + (1 << (j - 1));
                    if (ni >= blocks) {
                        blockTable[i][j] = blockTable[i][j - 1];
                    } else {
                        blockTable[i][j] = minHeight(blockTable[i][j - 1], blockTable[ni][j - 1]);
                    }
                }
            }

            // calc hashes of blocks
            for (int i = 0, blockId = 0, j = 0; i < countDfsOrder || j < block; ++i, ++j) {
                if (j == block) {
                    j = 0;
                    ++blockId;
                }
                if (j > 0 && (i >= countDfsOrder || minHeight(i - 1, i) == i - 1)) {
                    blockHash[blockId] += (1 << (j - 1));
                }
            }

            // precalc RMQ inside each unique block
            for (int i = 0; i < blocks; ++i) {
                int id = blockHash[i];
                if (blockRmq[id][0][0] != -1) continue;
                for (int l = 0; l < block; ++l) {
                    blockRmq[id][l][l] = l;
                    for (int r = l + 1; r < block; ++r) {
                        blockRmq[id][l][r] = blockRmq[id][l][r - 1];
                        if (i * block + r < countDfsOrder) {
                            blockRmq[id][l][r] = minHeight(i * block + blockRmq[id][l][r], i * block + r) - i * block;
                        }
                    }
                }
            }

            // precalc logarithms
            for (int i = 0, j = 0; i < countDfsOrder; ++i) {
                if (1 << (j + 1) <= i) ++j;
                log2[i] = j;
            }
        }

        int LCAInBlocks(int blockId, int l, int r) {
            return blockRmq[blockHash[blockId]][l][r] + blockId * block;
        }

        public int LCA(int v, int u) {
            int l = posInDfsOrder[v], r = posInDfsOrder[u];
            if (l > r) {
                int t = l;
                l = r;
                r = t;
            }
            int leftBlock = l / block, rightBlock = r / block;
            if (leftBlock == rightBlock) {
                return dfsOrder[LCAInBlocks(leftBlock, l % block, r % block)];
            }
            int ans1 = LCAInBlocks(leftBlock, l % block, block - 1);
            int ans2 = LCAInBlocks(rightBlock, 0, r % block);
            int ans = minHeight(ans1, ans2);
            if (leftBlock < rightBlock - 1) {
                int pw2 = log2[rightBlock - leftBlock - 1];
                int ans3 = blockTable[leftBlock + 1][pw2];
                int ans4 = blockTable[rightBlock - (1 << pw2)][pw2];
                ans = minHeight(ans, minHeight(ans3, ans4));
            }
            return dfsOrder[ans];
        }

    }

    static class Parent {
        public static int[] run(Graph tree, int root) {
            int[] parent = new int[tree.nVertex];
            int[] queue = new int[tree.nVertex];
            int front = 0, back = 0;
            queue[back++] = root;
            parent[root] = -1;
            while (front < back) {
                int v = queue[front++];
                for (int i = tree.first[v]; i != -1; i = tree.next[i]) {
                    if (parent[v] != tree.to[i]) {
                        queue[back++] = tree.to[i];
                        parent[tree.to[i]] = v;
                    }
                }
            }
            return parent;
        }

        public static int[][] getLevelParents(Graph tree, int root) {
            int maxLevel = 1;
            while ((1 << maxLevel) <= tree.nVertex) {
                ++maxLevel;
            }
            int[][] parent = new int[maxLevel][tree.nVertex];
            ArrayUtils.fill(parent, -1);
            parent[0] = Parent.run(tree, root);

            for (int level = 1; level < maxLevel; ++level) {
                for (int i = 0; i < tree.nVertex; ++i) {
                    if (parent[level - 1][i] != -1) {
                        int u = parent[level - 1][i];
                        if (parent[level - 1][u] != -1) {
                            int v = parent[level - 1][u];
                            parent[level][i] = v;
                        }
                    }
                }
            }
            return parent;
        }

        public static int[] getVertexLevels(Graph tree, int root, int[] parent) {
            int[] queue = new int[tree.nVertex];
            int front = 0, back = 0;
            queue[back++] = root;
            parent[root] = -1;
            int[] level = new int[tree.nVertex];
            level[root] = 0;
            while (front < back) {
                int v = queue[front++];
                for (int i = tree.first[v]; i != -1; i = tree.next[i]) {
                    if (parent[v] != tree.to[i]) {
                        queue[back++] = tree.to[i];
                        level[tree.to[i]] = level[v] + 1;
                    }
                }
            }
            return level;
        }

    }

    static class FenwickTreeSum {
        long[] sum;
        int n;

        public FenwickTreeSum(int n) {
            this.n = n;
            sum = new long[n + 1];
            Arrays.fill(sum, 0);
        }

        public void update(int position, long value) {
            ++position;
            for (int i = position; i <= n; i = next(i)) {
                sum[i] += value;
            }
        }

        private static int prev(int x) {
            return (x & (x - 1));
        }

        private static int next(int x) {
            return (x << 1) - prev(x);
        }

    }
}

