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) { Scanner in = new Scanner(System.in); int T = in.nextInt(); int p = 100003; BigInteger P = BigInteger.valueOf((long) p); for (int counter = 0; counter < T; counter++) { BigInteger n = new BigInteger(in.next()); BigInteger k = new BigInteger(in.next()); n = n.subtract(k).add(BigInteger.valueOf(1L)); int[] n_p = new int[4]; int[] k_p = new int[4]; BigInteger n_temp = n; BigInteger k_temp = k; for (int index = 3; index >= 0; index--) { n_p[index] = n_temp.mod(P).intValue(); n_temp = n_temp.divide(P); k_p[index] = k_temp.mod(P).intValue(); k_temp = k_temp.divide(P); } // System.out.println(Arrays.toString(n_p)); // System.out.println(Arrays.toString(k_p)); int[] fact_res = new int[100003]; int[] fact_inv = new int[100003]; fact_res[0] = 1; fact_inv[0] = 1; for (int index = 1; index < 100003; index++) { fact_res[index] = (int) (((long) fact_res[index - 1] * (long) index) % (long) p); fact_inv[index] = BigInteger.valueOf(fact_res[index]).modInverse(P).intValue();; } // System.out.println(Arrays.toString(Arrays.copyOfRange(fact_res, 0, 11))); // System.out.println(Arrays.toString(Arrays.copyOfRange(fact_inv, 0, 11))); long res = 1; for (int index = 0; index < 4; index++) { int N = n_p[index]; int K = k_p[index]; if (K > N) { res = 0; break; } else { res *= fact_res[N]; res %= p; res *= fact_inv[N - K]; res %= p; res *= fact_inv[K]; res %= p; } } System.out.println(res); } } }