Kitty's Calculations on a Tree
Kitty has a tree , consisting of nodes where each node is uniquely labeled from to . Her friend Alex gave her sets, where each set contains distinct nodes. Kitty needs to calculate the following expression on each set:
where:
denotes an unordered pair of nodes belonging to the set.
denotes the number of edges on the unique (shortest) path between nodes and .
Given and sets of distinct nodes, calculate the expression for each set. For each set of nodes, print the value of the expression modulo on a new line.
Input
The first line contains two integers: the number of nodes in tree and — the number of nodes in the query set.
Each of the subsequent lines contains two integers and , that describe an undirected edge between nodes and .
The subsequent lines define each set over two lines in the following format:
The first line contains an integer — the size of the set;
The second line contains integers, the set's elements , the sum of over all does not exceed .
Output
Print lines where each line contains the expression for the -th query, modulo .