import java.io.FileInputStream; import java.io.FileNotFoundException; import java.math.BigInteger; import java.util.Scanner; public class Solution { private static long MOD = 100003; private static BigInteger MOD_BI = new BigInteger(Integer.toString((int) MOD)); public static void main(String[] args) throws FileNotFoundException { Scanner in = new Scanner(System.in); int numberOfTests = in.nextInt(); while (numberOfTests-- > 0) { long N = in.nextLong(); long K = in.nextLong(); // N - K + 1 choose K System.out.println(binomialBigInteger(N - K + 1, K)); } } private static long iterativeBinomial(long N, long K) { long runningFactorial = 1; if (K > N){ return 0; } for (long denominator = 1; denominator <= K; denominator++) { runningFactorial *= N--; runningFactorial /= denominator; } return runningFactorial % MOD; } private static long testing(long N, long K) { long runningFactorial = 1; if (N - K < K) { for (int i = 1; i <= N - K; i++) { runningFactorial = runningFactorial * (1 + (K / i)); } } else { for (int i = 1; i <= K; i++) { runningFactorial = runningFactorial * (1 + (N - K) / i); runningFactorial = runningFactorial % MOD; } } return runningFactorial; } private static BigInteger factorialFromRangeBI(long iterations, int numberToCountDownFrom) { BigInteger factorial = new BigInteger(Integer.toString(1)); BigInteger numberToCountDownFromBi = new BigInteger(Integer.toString(numberToCountDownFrom)); while (iterations-- > 0) { factorial = factorial.multiply(numberToCountDownFromBi); numberToCountDownFromBi = numberToCountDownFromBi.subtract(BigInteger.ONE); } return factorial; } private static String getNumberOfWaysWithTalkElimination(long N, long K) { // N ? K + 1 choose K N = N - K + 1; if (N < K) { return "0"; } // Factor out what needs to be factorial'd BigInteger top = factorialFromRangeBI(N - K, (int) N); BigInteger bottom = factorialFromRangeBI(1, (int) (N - K)); BigInteger finalAnser = top.divide(bottom); return finalAnser.mod(BigInteger.valueOf(MOD)).toString(); } private static long getNumberOfWaysWithSimplification(long N, long K) { // N ? K + 1 choose K N = N - K + 1; if (N < K) { return 0; } // Factor out what needs to be factorial'd double top = factorialFromRange(N - K, N); double bottom = factorial(N - K); return Math.round(top / bottom); } private static long factorialFromRange(long iterations, long numberToCountDownFrom) { long factorial = 1; while (iterations-- > 0) { factorial = factorial * numberToCountDownFrom; factorial = factorial % MOD; numberToCountDownFrom--; } return factorial; } private static long factorial(long number) { long factorial = number; while (--number > 0) { factorial = factorial * number; factorial = factorial % MOD; } return factorial; } private static long binomialThree(long N, long K) { long result = 1L; for (double i = 1; i <= K; i++) { result *= (N - K + i) / i; } return Math.round(result % MOD); } private static long otherBinomial(long N, long K) { int i = 0; long runningBinomial = 1; while (i < K) { runningBinomial = (runningBinomial * ((N - i) / (K - i))) % MOD; i++; } return runningBinomial; } private static long getNumberOfWaysNonConsecutively(long N, long K) { // N ? K + 1 choose K N = N - K + 1; if (N < K) { return 0; } long top = factorial(N); long partOfBottomOne = factorial(K); long partOfBottomTwo = factorial(N - K); long bottom = partOfBottomOne * partOfBottomTwo % MOD; return top / bottom; } private static BigInteger binomialBigInteger(long N, long K) { if (N <= K) { return BigInteger.valueOf(0); } BigInteger top = factorial(BigInteger.valueOf(N)); BigInteger partOfBottomOne = factorial(BigInteger.valueOf(K)); BigInteger partOfBottomTwo = factorial(BigInteger.valueOf(N - K)); BigInteger bottom = partOfBottomOne.multiply(partOfBottomTwo); BigInteger finalValue = top.divide(bottom); return finalValue.mod(MOD_BI); } public static BigInteger factorial(BigInteger number) { BigInteger result = BigInteger.ONE; while (!number.equals(BigInteger.ZERO)) { result = result.multiply(number); number = number.subtract(BigInteger.ONE); } return result; } private static BigInteger factorialBI(int number) { BigInteger biN = new BigInteger(Integer.toString(number)); BigInteger value = new BigInteger(Integer.toString(number)); while (--number > 0) { value = value.multiply(BigInteger.valueOf(number)); } return biN; } }