#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

// (num ^ x) % mod
LL pow_mod(LL num, LL x, LL mod)
{
	LL res = 1;
	while (x > 0)
	{
		if (x & 1)
		{
			res = (res * num) % mod;
		}
		num = (num * num) % mod;
		x >>= 1;
	}
	return res;
}

// ユークリッドの互除法
LL extgcd(LL a, LL b, LL& x, LL& y)
{
	LL g = a; x = 1; y = 0;
	if (b != 0)
	{
		g = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	return g;
}

// 逆元
LL mod_inverse(LL a, LL m)
{
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

// 階乗
std::vector<LL>fact;
void mod_fact(LL n, LL m)
{
	fact.resize(n + 1);
	fact[0] = 1;
	for (LL i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % m;
}

const LL mod = 1000003;

int main()
{
	LL Q;
	in >> Q;
	std::vector<LL>x(Q), d(Q), n(Q);
	rep(i, Q) in >> x[i] >> d[i] >> n[i];

	mod_fact(2123456, mod);
	rep(i, Q)
	{
		LL ans;
		if (d[i] == 0) ans = pow_mod(x[i], n[i], mod);
		else
		{
			if (n[i] >= mod) ans = 0;
			else
			{
				LL X = x[i] * mod_inverse(d[i], mod) % mod;
				ans = fact[X + n[i] - 1] * mod_inverse(fact[X - 1], mod) % mod * pow_mod(d[i], n[i], mod) % mod;
			}
		}
		out << ans << std::endl;
	}
}

### Prompt

Please provide a Cpp coded solution 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"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

// (num ^ x) % mod
LL pow_mod(LL num, LL x, LL mod)
{
	LL res = 1;
	while (x > 0)
	{
		if (x & 1)
		{
			res = (res * num) % mod;
		}
		num = (num * num) % mod;
		x >>= 1;
	}
	return res;
}

// ユークリッドの互除法
LL extgcd(LL a, LL b, LL& x, LL& y)
{
	LL g = a; x = 1; y = 0;
	if (b != 0)
	{
		g = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	return g;
}

// 逆元
LL mod_inverse(LL a, LL m)
{
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

// 階乗
std::vector<LL>fact;
void mod_fact(LL n, LL m)
{
	fact.resize(n + 1);
	fact[0] = 1;
	for (LL i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % m;
}

const LL mod = 1000003;

int main()
{
	LL Q;
	in >> Q;
	std::vector<LL>x(Q), d(Q), n(Q);
	rep(i, Q) in >> x[i] >> d[i] >> n[i];

	mod_fact(2123456, mod);
	rep(i, Q)
	{
		LL ans;
		if (d[i] == 0) ans = pow_mod(x[i], n[i], mod);
		else
		{
			if (n[i] >= mod) ans = 0;
			else
			{
				LL X = x[i] * mod_inverse(d[i], mod) % mod;
				ans = fact[X + n[i] - 1] * mod_inverse(fact[X - 1], mod) % mod * pow_mod(d[i], n[i], mod) % mod;
			}
		}
		out << ans << std::endl;
	}
}

```