GTW likes czf

Time Limit: 2000ms
Memory Limit: 131072KB
This problem will be judged on HDU. Original ID: 5598
64-bit integer IO format: %I64d      Java class name: Main

Description

Long long age, there were two people named GTW and DSY, respectively. One day, in order to contend for CZF, the young girl of DSY, they decided to have a duel.

To start with, the two people were given a range, $l,l + 1,l + 2,...,r$, and two numbers, $G$ and $T$. Then, CZF chose either $G$ or $T$ as a number $X$ randomly, and chose an integer $Y$ in the range $[l, r]$ randomly, to perform a special operation, @, which is defined as that X @ Y =((X and Y) or Y) xor X. CZF wanted to know the number of numbers which could be the answer.

Nevertheless, GTW was not able to tackle this problem. In order to win CZF, he asked for your help.

Because the answer can be very large, you only need to print the answer modulo 1000000007.

Input

The first line of the input file contains exactly one integer, $T$, indicating the number of test cases. $(T\leq 10000)$

In the following $T$ lines, each line indicates a test case, containing 4 integers, $l, r, g, t$, whose meanings are given above. ($1\leq l,r,g,t\leq 10^{18},l\leq r$)

Output

There should be $T$ lines in the output file.

In each line of the output file, there should be exactly one number, indicating the answer of the test case respectively.

Sample Input

1
2 4 2 4

Sample Output

4

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .