The Struggle

아직 제출이 없습니다시간 제한4.5초메모리 제한512 MB

문제

Nocriz is a student who, like many, has a dream for his life. Unfortunately, life isn't always easy, and there are times when the dream seems far away and the pursuit feels difficult. 

Reality often drives people away from their pursuit of dreams to settle for what they have at hand. Lured to set aside the struggle, Nocriz said to Artemisia, "But I shouldn't give up the dream, right?". Artemisia replied: "Of course one should not give up the dream easily! Struggle, struggle until you are crushed by a rock!".

That night, Nocriz had a very bad dream. In his dream, there was a rock in the shape of an ellipse, and he was asked to calculate the sum of values (xy)33x2y1(x \oplus y)^{33} x^{-2} y^{-1}, performing the calculations modulo 109+710^9 + 7, for all integer points (x,y)(x, y) in the ellipse, where \oplus is the bitwise XOR operation.

Formally, the ellipse is specified by six integers aa, bb, cc, dd, ee, ff. Consider the ellipse E=(x,y)x,yZ,,a(xb)2+c(yd)2+e(xb)(yd)fE = \\{(x, y) \mid x, y \in \mathbb{Z}, \\, a (x - b)^2 + c (y - d)^2 + e (x - b) (y - d) \le f\\}. It is guaranteed that all points of the ellipse satisfy 0<x,y<41060 < x, y < 4 \cdot 10^6, and that the ellipse contains at least one integer point. Now, consider the coordinates as residues modulo 109+710^9 + 7, and calculate _(x,y)E (xy)33x2y1.\sum\_{(x, y) \in E}  (x \oplus y)^{33} x^{-2} y^{-1}\text{.} In particular, considering numbers as residues means that z1z^{-1} is the modular inverse of zz, and the result of every addition and multiplication has to be taken modulo 109+710^9 + 7.

Nocriz was not crushed by the rock that day. Can you solve this problem, like Nocriz did?

입력

The first line contains an integer TT (1T1041 \le T \le 10^4), the number of test cases. Then TT test cases follow.

The first and only line of each test case contains six integers aa, bb, cc, dd, ee, ff (1a,c1001 \le a, c \le 100, 100e100-100 \le e \le 100, 1b,d41061 \le b, d \le 4 \cdot 10^6, 0f10150 \le f \le 10^{15}). It is guaranteed that all points (x,y)(x, y) of the ellipse satisfy 0<x,y<41060 < x, y < 4 \cdot 10^6, and that the ellipse contains at least one integer point.

It is also guaranteed that the sum of the values max_(x,y)Emax(x,y)\displaystyle \max\limits\_{(x, y) \in E} \max(x, y) over all test cases is at most 41064 \cdot 10^6.

출력

For each test case, output a single line with the integer representing the answer. Don't forget to treat coordinates as residues modulo 109+710^9 + 7 in calculations.