Problem:
Score : 600 points

Problem Statement

Consider the following arithmetic progression with n terms:

x, x + d, x + 2d, \ldots, x + (n-1)d

What is the product of all terms in this sequence?
Compute the answer modulo 1\ 000\ 003.

You are given Q queries of this form.
In the i-th query, compute the answer in case x = x_i, d = d_i, n = n_i.

Constraints

1 \leq Q \leq 10^5

0 \leq x_i, d_i \leq 1\ 000\ 002

1 \leq n_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

Q
x_1 d_1 n_1
:
x_Q d_Q n_Q

Output

Print Q lines.

In the i-th line, print the answer for the i-th query.

Sample Input 1

2
7 2 4
12345 67890 2019

Sample Output 1

9009
916936

For the first query, the answer is 7 \times 9 \times 11 \times 13 = 9009.
Don't forget to compute the answer modulo 1\ 000\ 003.

Solution in PyPy3 (2.4.0) (judge verdict: Wrong Answer)


"""
可能性:
数学的にO(1)→濃厚
前準備して瞬殺→全部違うからありえなさそう

展開式から計算？→結局n項になっちゃう…

1つ項が進むと、mod1000003はd個右にずれる(右端でループ)
→0に来ることがあれば必ず0

d,n固定の時、x1の結果からx2の結果を導出できればlogNで解ける
→そんなシンプルにはいかなそう…

========解答を見た=========
？？？？？？
分かるけど…どういうこと…

→簡単に解ける問題に落とし込むのか…
→制約が簡単verを色々考慮し、落とし込めないか考えるべきだった

"""

def inverse(a,mod): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)

def modfac(n, MOD):
 
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


def modnCr(n,r,mod,fac,inv): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる)

    return fac[n] * inv[n-r] * inv[r] % mod

mod = 10 ** 6 + 3
fac,inv = modfac(mod-1, mod)

#print (len(inv))
Q = int(input())

for i in range(Q):

    x,d,n = map(int,input().split())

    if d == 0 and x == 0:
        print (pow(x,n,mod))
        continue
    elif x == 0:
        ans = fac[(n-1) % mod]
        ans *= pow(d,n-1,mod)
        print (ans % mod)
        continue
    elif d == 0:
        print (pow(x,n,mod))
    elif n == 1:
        print (x)
        continue

    fi = x * inverse(d,mod) % mod
    
    if fi + n >= mod or fi % mod == 0:
        print (0)
        continue

    #print (pow(d,n,mod) , fac[fi+n-1] , inv[fi-1] , mod)
    if fi >= 2:
        print (pow(d,n,mod) * fac[(fi+n-1) % mod] * inv[(fi-1) % mod] % mod)
    else:
        print (pow(d,n,mod) * fac[(fi+n-1) % mod]  % mod)