//Heaplax
#include<bits/stdc++.h>
#define N 1000005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int mod=1000003;
int q;
int x,d,n;
int fac[N],ifac[N],inv[N];
int mi(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return res;
}
int main()
{
	inv[0]=inv[1]=ifac[0]=fac[0]=1;
	for(int i=1;i<N;++i)
	{
		if(i>1)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fac[i]=1ll*fac[i-1]*i%mod;
		ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
	}
	re(q);
	while(q--)
	{
		re(x),re(d),re(n);
		if(!d)
		{
			printf("%d\n",mi(x,n));
			continue;
		}
		int w=1ll*(mod-x)*mi(d,mod-2)%mod;
		if(n-1>=w || (!x && n>mod))
		{
			puts("0");
			continue;
		}
		x=1ll*x*mi(d,mod-2)%mod;
		if(x+n-1>=mod)
		{
			puts("0");
			continue;
		}
		int ans=1ll*mi(d,n)*(x?ifac[x-1]:1)%mod;
		ans=1ll*ans*fac[x+n-1]%mod;
		printf("%d\n",ans);
	}
}

### 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
//Heaplax
#include<bits/stdc++.h>
#define N 1000005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int mod=1000003;
int q;
int x,d,n;
int fac[N],ifac[N],inv[N];
int mi(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return res;
}
int main()
{
	inv[0]=inv[1]=ifac[0]=fac[0]=1;
	for(int i=1;i<N;++i)
	{
		if(i>1)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fac[i]=1ll*fac[i-1]*i%mod;
		ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
	}
	re(q);
	while(q--)
	{
		re(x),re(d),re(n);
		if(!d)
		{
			printf("%d\n",mi(x,n));
			continue;
		}
		int w=1ll*(mod-x)*mi(d,mod-2)%mod;
		if(n-1>=w || (!x && n>mod))
		{
			puts("0");
			continue;
		}
		x=1ll*x*mi(d,mod-2)%mod;
		if(x+n-1>=mod)
		{
			puts("0");
			continue;
		}
		int ans=1ll*mi(d,n)*(x?ifac[x-1]:1)%mod;
		ans=1ll*ans*fac[x+n-1]%mod;
		printf("%d\n",ans);
	}
}

```