#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
ll modi(ll a,ll m){
  ll b=m,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b;
    swap(a,b);
    u-=t*v;
    swap(u,v);
  }
  u%=m;
  if(u<0) u+=m;
  return u;
}
ll modp(ll a,ll b,ll m){
  if(b==0) return 1;
  if(b%2) return modp(a,b-1,m)*a%m;
  return modp(a,b/2,m)*modp(a,b/2,m)%m;
}
int main(){
  int Q;
  cin>>Q;
  vector<int> X(Q),D(Q),N(Q);
  rep(i,Q) cin>>X[i]>>D[i]>>N[i];
  int mod=1000003;
  vector<ll> A(mod);
  A[0]=1;
  rep(i,mod) if(i) A[i]=A[i-1]*i%mod;
  ll ans;
  rep(i,Q){
    if(D[i]){
      ll B=(X[i]*modi(D[i],mod)+N[i]-1)%mod;
      if(B<0) B+=mod;
      ll C=(X[i]*modi(D[i],mod)-1)%mod;
      if(C<0) C+=mod;
      if(N[i]>=mod||B%mod<=C%mod) ans=0;
      else{
        ans=A[B]*modi(A[C],mod)%mod;
        ans=ans*modp(D[i],N[i],mod)%mod;
        if(ans<0) ans+=mod;
      }
      cout<<ans<<endl;
    }else{
      ans=modp(X[i],N[i],mod)%mod;
      if(ans<0) ans+=mod;
      cout<<ans<<endl;
    }
  }
}
### Prompt

Develop a solution in CPP to the problem described below:

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>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
ll modi(ll a,ll m){
  ll b=m,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b;
    swap(a,b);
    u-=t*v;
    swap(u,v);
  }
  u%=m;
  if(u<0) u+=m;
  return u;
}
ll modp(ll a,ll b,ll m){
  if(b==0) return 1;
  if(b%2) return modp(a,b-1,m)*a%m;
  return modp(a,b/2,m)*modp(a,b/2,m)%m;
}
int main(){
  int Q;
  cin>>Q;
  vector<int> X(Q),D(Q),N(Q);
  rep(i,Q) cin>>X[i]>>D[i]>>N[i];
  int mod=1000003;
  vector<ll> A(mod);
  A[0]=1;
  rep(i,mod) if(i) A[i]=A[i-1]*i%mod;
  ll ans;
  rep(i,Q){
    if(D[i]){
      ll B=(X[i]*modi(D[i],mod)+N[i]-1)%mod;
      if(B<0) B+=mod;
      ll C=(X[i]*modi(D[i],mod)-1)%mod;
      if(C<0) C+=mod;
      if(N[i]>=mod||B%mod<=C%mod) ans=0;
      else{
        ans=A[B]*modi(A[C],mod)%mod;
        ans=ans*modp(D[i],N[i],mod)%mod;
        if(ans<0) ans+=mod;
      }
      cout<<ans<<endl;
    }else{
      ans=modp(X[i],N[i],mod)%mod;
      if(ans<0) ans+=mod;
      cout<<ans<<endl;
    }
  }
}
```