stars

Time Limit: 20000/10000 MS (Java/Others)

Memory Limit: 32768/32768 K (Java/Others)

Description

John loves to see the sky. A day has Q times. Each time John will find a new star in the sky, or he wants to know how many stars between $(x_1, y_1, z_1)$ and $(x_2, y_2, z_2)$.

Input

The first line contains a single integer $T(1 \leq T \leq 10)$ (the data for $Q > 100$ less than 6 cases),, indicating the number of test cases.
The first line contains an integer $Q(1 \leq Q \leq 50000)$,indicating how many times in a day.
Next Q lines contain some integers, first input an integer $A(1 \leq A \leq 2)$.If A=1 then input 3 integers x, y and z, indicating a coordinate of one star.. If A=2 then input 6 integers $x_1, y_1, z_1, x_2, y_2, z_2(1 \leq x, y, z, x_1, y_1, z_1, x_2, y_2, z_2 \leq 10^9, x_1 \leq x_2, y_1 \leq y_2, z_1 \leq z_2)$.

Output

For each “A=2”,output an integer means how many stars in such a section.

Sample Input

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

Sample Output

1
3
7
4
1
3
7
4

heyang

Source

BestCoder Round #20