import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ BigInteger MOD = BigInteger.valueOf(100003); BigInteger n = BigInteger.valueOf(0), k = BigInteger.valueOf(0), p = BigInteger.valueOf(0); int tests = 0; Scanner in = new Scanner(System.in); tests = in.nextInt(); for(; tests > 0; tests--){ n = in.nextBigInteger().mod(MOD); k = in.nextBigInteger().mod(MOD); p = BigInteger.ONE; if(k.compareTo(n.add(BigInteger.ONE).subtract(k)) > 0){ p = BigInteger.ZERO; System.out.println(p.toString()); continue; } p = factorial(n.add(BigInteger.ONE).subtract(k), n.add(BigInteger.ONE).subtract(k).subtract(k), MOD); p = p.multiply(factorial(k,BigInteger.ONE, MOD).modInverse(MOD)).mod(MOD); System.out.println(p.toString()); } } static BigInteger factorial(BigInteger n, BigInteger m, BigInteger MOD){ BigInteger result = BigInteger.ONE; // if(n.compareTo(BigInteger.ZERO) < 1) return BigInteger.ZERO; // if(m.compareTo(BigInteger.ZERO) < 1) return BigInteger.ZERO; n = n.mod(MOD); m = m.mod(MOD); for(BigInteger i = n; i.compareTo(m) > 0; i = i.subtract(BigInteger.ONE)){ result = result.mod(MOD).multiply(i).mod(MOD); } // System.out.println("factorial: "+ n.toString() + " " + m.toString() + " " + result.toString()); return result; } }