static void Method(string[] args) { int q = ReadInt(); long mask = 1000003; var calculator = new CaseCalculator(mask, mask + 100); for (int i = 0; i < q; i++) { long[] xdn = ReadLongs(); long x = xdn[0]; long d = xdn[1]; long n = xdn[2]; if (d == 0) { WriteLine(calculator.Pow(x, n)); } else { long baseVal = calculator.Multi(x, calculator.Inverse(d)); if (baseVal + n - 1 >= mask) { WriteLine(0); } else { WriteLine(calculator.Multi( calculator.Permutation(baseVal + n - 1, n), calculator.Pow(d, n))); } } } }