Alice and Bob are visiting Byteland. They are observing the map of this country. Surprisingly, the map of Byteland forms a tree. A tree is a connected graph without cycles. After finding this out, Alice has fixed the starting and ending city of her journey. But Bob is super confused and can’t fix his route.
After some thinking, Bob has come up with a scheme. Let’s say Alice’s starting city is and ending city is . Then Bob will choose two different cities and such that both and lie on the simple path between city and city . A simple path is the path that visits each city at most once. Soon Bob finds out that there are still many options. So, he is considering all possible options. For each option of choosing two different cities and , he calculates the cost of the simple path between cities and and appends it to the list . After appending the costs of all options, he sorts the list in ascending order. Please note that choosing cities and cities are considered as the same option.
Each edge of the tree has some weight. Bob defines the cost of a simple path as the bit-wise XOR of all the weights of the edges lying on that simple path.
Now, Bob wants to analyze the costs in subarray of the list . He wants your help to analyze this task. You need to calculate the product of all the costs in subarray of the list . As the answer can be very large, you need to print the answer modulo . More formally, you need to print .
The bitwise xor operation is represented with the "⊕" logic symbol, which is denoted as the "^" operator in C/C++, Java and Python.
The first line of the input will contain an integer , the number of the test cases.
In each of the test cases, the first line will contain two integers , the number of cities in Byteland, and the number of queries. Each of the next lines will contain three integers denoting there is an undirected edge of weight between city and city . Each of the next lines will contain four integers , the starting and ending cities of Alice and the list ’s range Bob will analyze.
It is guaranteed that the given edges form a tree and the , will produce a valid range.
The sum of over all test cases won’t exceed and the sum of over all test cases won’t exceed .
In each query, print in a line.
1 5 2 1 2 6 2 3 13 2 5 12 3 4 5 4 5 2 4 1 3 1 3
In the first query, the costs of the paths Bob will consider are:
So, the list will be: .