#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1000003;

ll kuri2(ll base,ll kata)
{
	ll ret=1;
	if(kata==0)
		return ret;
	else if(kata&1){
		ret*=base;
		ret%=MOD;
	}
	ret*=kuri2(base*base%MOD,(kata>>1));
	ret%=MOD;
	return ret;
}

ll kai[1000003];
ll gyaku[1000003];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int q;
	ll ans=0;
	//階乗を求める
	kai[0]=1;
	gyaku[0]=kuri2(kai[0],MOD-2);
	for(ll i=1;i<MOD;i++)
	{
		kai[i]=kai[i-1]*i;
		kai[i]%=MOD;
		if(kai[i]<0)
			kai[i]+=MOD;
		gyaku[i]=kuri2(kai[i],MOD-2);
	}
	cin>>q;
	for(int i=0;i<q;i++)
	{
		ll x,d,n;
		cin>>x>>d>>n;
		//例外処理
		if(x==0)
		{
			cout<<0<<endl;
			continue;
		}
		if(d==0)
		{
			cout<<kuri2(x,n)<<endl;
			continue;
		}
		//cerr<<d*kuri2(d,MOD-2)%MOD<<endl;
		ll xd=x*kuri2(d,MOD-2);//x/dを求める
		xd%=MOD;
		if(xd<0)
			xd+=MOD;
		//MODを含むなら答えは0
		if(xd+n-1>=MOD)
		{
			ans=0;
		}else{
			//そうでない場合は頑張って求める
			ans=kai[xd+n-1]*gyaku[xd-1];
			ans%=MOD;
			ans*=kuri2(d,n);
			ans%=MOD;
			if(ans<0)
				ans+=MOD;
		}
		cout<<ans<<endl;
	}
	return 0;
}
### Prompt

Your task is to create 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 <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1000003;

ll kuri2(ll base,ll kata)
{
	ll ret=1;
	if(kata==0)
		return ret;
	else if(kata&1){
		ret*=base;
		ret%=MOD;
	}
	ret*=kuri2(base*base%MOD,(kata>>1));
	ret%=MOD;
	return ret;
}

ll kai[1000003];
ll gyaku[1000003];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int q;
	ll ans=0;
	//階乗を求める
	kai[0]=1;
	gyaku[0]=kuri2(kai[0],MOD-2);
	for(ll i=1;i<MOD;i++)
	{
		kai[i]=kai[i-1]*i;
		kai[i]%=MOD;
		if(kai[i]<0)
			kai[i]+=MOD;
		gyaku[i]=kuri2(kai[i],MOD-2);
	}
	cin>>q;
	for(int i=0;i<q;i++)
	{
		ll x,d,n;
		cin>>x>>d>>n;
		//例外処理
		if(x==0)
		{
			cout<<0<<endl;
			continue;
		}
		if(d==0)
		{
			cout<<kuri2(x,n)<<endl;
			continue;
		}
		//cerr<<d*kuri2(d,MOD-2)%MOD<<endl;
		ll xd=x*kuri2(d,MOD-2);//x/dを求める
		xd%=MOD;
		if(xd<0)
			xd+=MOD;
		//MODを含むなら答えは0
		if(xd+n-1>=MOD)
		{
			ans=0;
		}else{
			//そうでない場合は頑張って求める
			ans=kai[xd+n-1]*gyaku[xd-1];
			ans%=MOD;
			ans*=kuri2(d,n);
			ans%=MOD;
			if(ans<0)
				ans+=MOD;
		}
		cout<<ans<<endl;
	}
	return 0;
}
```