#include <bits/stdc++.h>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}

typedef long long ll;
const int mod = 1e6 + 3;
const int maxn = 2e6 + 10;
ll fac[maxn], fin[maxn];
int x, d, n;

ll power(ll x, ll n){
  ll y = 1;
  for(; n; n >>= 1, x = x * x % mod)
    if(n & 1) y = y * x % mod;
  return y;
}

#define inv(x) power(x, mod - 2)

void init(int n){
  fac[0] = 1; rep(i, 1, n) fac[i] = fac[i - 1] * i % mod;
  fin[n] = inv(fac[n]);
  per(i, n, 1) fin[i - 1] = fin[i] * i % mod;
}

void work(){
  rd(x), rd(d), rd(n);
  if(d == 0){
    printf("%lld\n", power(x, n));
    return ;
  }
  if(x == 0){
    printf("%lld\n", fac[n] * power(d, n) % mod);
    return ;
  }
  ll t = (ll) x * inv(d) % mod;
  if(n >= mod || t + n - 1 >= mod) return (void) (puts("0"));
  printf("%lld\n", fac[t + n - 1] * fin[t - 1] % mod * power(d, n) % mod);
}

int main(){
  init(mod - 1);
  int q; rd(q);
  while(q --) work();
  return 0;
}


### Prompt

Generate a cpp solution to the following problem:

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.

Example

Input

2
7 2 4
12345 67890 2019


Output

9009
916936

### Response

```cpp
#include <bits/stdc++.h>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}

typedef long long ll;
const int mod = 1e6 + 3;
const int maxn = 2e6 + 10;
ll fac[maxn], fin[maxn];
int x, d, n;

ll power(ll x, ll n){
  ll y = 1;
  for(; n; n >>= 1, x = x * x % mod)
    if(n & 1) y = y * x % mod;
  return y;
}

#define inv(x) power(x, mod - 2)

void init(int n){
  fac[0] = 1; rep(i, 1, n) fac[i] = fac[i - 1] * i % mod;
  fin[n] = inv(fac[n]);
  per(i, n, 1) fin[i - 1] = fin[i] * i % mod;
}

void work(){
  rd(x), rd(d), rd(n);
  if(d == 0){
    printf("%lld\n", power(x, n));
    return ;
  }
  if(x == 0){
    printf("%lld\n", fac[n] * power(d, n) % mod);
    return ;
  }
  ll t = (ll) x * inv(d) % mod;
  if(n >= mod || t + n - 1 >= mod) return (void) (puts("0"));
  printf("%lld\n", fac[t + n - 1] * fin[t - 1] % mod * power(d, n) % mod);
}

int main(){
  init(mod - 1);
  int q; rd(q);
  while(q --) work();
  return 0;
}


```