Problem hidden

POWRTU - Power with Combinatorics(EASY)

Your task is to calculate a^(b^(exp))

a: provided in input, 0 ≤ a ≤ 500

b: provided in input, 0 ≤ b ≤ 500

exp = (nC0)2 + (nC1)2 + (nC2)2 + ... + (nCn)2

n: provided in input, 0 ≤ n ≤ 500

Note: The Output for 00 should be 1.

Where nCr denotes n choose r.

As the answer can be too large, you need to output modulo 109+7.

Input

The first line of each input file contains number of test cases t (t ≤ 1000).

Then follow a new line.

Then follow t lines, each containing 3 integers, (i.e. a b n in order) each of them separated by a space.

Output

Write t lines, ith line contains the answer of the ith test case.

Example

Input:
1
1 1 1

Output:
1

Explanation

In first test case, the Value of exp is 2, value of 112 is 1, so output is 1.

Click here to see my set of problems at SPOJ.


Adicionado por:devu
Data:2012-07-14
Tempo limite:1.111s
Tamanho do fonte:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Linguagem permitida:Todas exceto: ASM64 CLOJURE ERL FSHARP PERL6 PY_NBC SCALA TCL
Origem:Utkarsh Lath
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.