#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e6+3;
int n,q,x,d;
LL fac[2000010],ans,inv[2000010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
int main(){
	fac[0]=1;
	FOR(i,1,1000002) fac[i]=fac[i-1]*i%MO;
	inv[1000002]=pw(fac[1000002],MO-2);
	FORD(i,1000001,0) inv[i]=inv[i+1]*(i+1)%MO;
	cin>>q;
	while (q--){
		cin>>x>>d>>n;
		if (d==0){
			ans=pw(x,n);
		}
		else{
			x=1ll*x*pw(d,MO-2)%MO;
			x=(x%MO+MO)%MO;
			if (x+n-1>=1000003 || x==0) ans=0;
			else{
				ans=fac[x+n-1]*inv[x-1]%MO;
				ans=ans*pw(d,n)%MO;
			}
		}
		ans=(ans%MO+MO)%MO;
		printf("%lld\n",ans);
	}
	return 0;
}
### Prompt

Construct a CPP code solution to the problem outlined:

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 pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e6+3;
int n,q,x,d;
LL fac[2000010],ans,inv[2000010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
int main(){
	fac[0]=1;
	FOR(i,1,1000002) fac[i]=fac[i-1]*i%MO;
	inv[1000002]=pw(fac[1000002],MO-2);
	FORD(i,1000001,0) inv[i]=inv[i+1]*(i+1)%MO;
	cin>>q;
	while (q--){
		cin>>x>>d>>n;
		if (d==0){
			ans=pw(x,n);
		}
		else{
			x=1ll*x*pw(d,MO-2)%MO;
			x=(x%MO+MO)%MO;
			if (x+n-1>=1000003 || x==0) ans=0;
			else{
				ans=fac[x+n-1]*inv[x-1]%MO;
				ans=ans*pw(d,n)%MO;
			}
		}
		ans=(ans%MO+MO)%MO;
		printf("%lld\n",ans);
	}
	return 0;
}
```