#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

lint modinv(lint a,lint m){
	lint b=m,u=1,v=0;
	while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
	return (u+m)%m;
}

lint modpow(lint a,lint k,int m){
	lint r=1;
	for(lint x=a%m;k>0;k>>=1,x=x*x%m) if(k&1) r=r*x%m;
	return r;
}

constexpr int MOD=1000003;

int main(){
	vector<lint> fact(MOD);
	fact[0]=1;
	rep(i,MOD-1) fact[i+1]=fact[i]*(i+1)%MOD;

	int q; scanf("%d",&q);
	rep(_,q){
		lint x,d,n; scanf("%lld%lld%lld",&x,&d,&n);

		lint ans;
		if(x==0){
			ans=0;
		}
		else if(d==0){
			ans=modpow(x,n,MOD);
		}
		else{
			lint p=modinv(d,MOD)*x%MOD;
			if(p+n-1>=MOD){
				ans=0;
			}
			else{
				ans=fact[p+n-1]*modinv(fact[p-1],MOD)%MOD;
				ans=ans*modpow(d,n,MOD)%MOD;
			}
		}
		printf("%lld\n",ans);
	}

	return 0;
}

### Prompt

Please create a solution in CPP 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(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

lint modinv(lint a,lint m){
	lint b=m,u=1,v=0;
	while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
	return (u+m)%m;
}

lint modpow(lint a,lint k,int m){
	lint r=1;
	for(lint x=a%m;k>0;k>>=1,x=x*x%m) if(k&1) r=r*x%m;
	return r;
}

constexpr int MOD=1000003;

int main(){
	vector<lint> fact(MOD);
	fact[0]=1;
	rep(i,MOD-1) fact[i+1]=fact[i]*(i+1)%MOD;

	int q; scanf("%d",&q);
	rep(_,q){
		lint x,d,n; scanf("%lld%lld%lld",&x,&d,&n);

		lint ans;
		if(x==0){
			ans=0;
		}
		else if(d==0){
			ans=modpow(x,n,MOD);
		}
		else{
			lint p=modinv(d,MOD)*x%MOD;
			if(p+n-1>=MOD){
				ans=0;
			}
			else{
				ans=fact[p+n-1]*modinv(fact[p-1],MOD)%MOD;
				ans=ans*modpow(d,n,MOD)%MOD;
			}
		}
		printf("%lld\n",ans);
	}

	return 0;
}

```