import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Solution { final static int MODVAL = 100003; //final static int MODVAL = 7; final static long[] factorials = genFactorials(); private static long[] genFactorials() { long[] fact = new long[MODVAL]; fact[0] = 1; for(int i = 1; i < MODVAL; i ++) { fact[i] = (fact[i-1]*i)%MODVAL; } return fact; } public static void main(String[] args) throws IOException { Scanner read = new Scanner(System.in); int numT = read.nextInt(); for (int t = 0; t < numT; t++) { long houses = read.nextLong(); long visits = read.nextLong(); System.out.println(nCr(houses-visits+1,visits)); } } public static int nCr(long n, long r) { if(r>n)return 0; FactorialInfo ni = new FactorialInfo(n); FactorialInfo d1i = new FactorialInfo(r); FactorialInfo d2i = new FactorialInfo(n-r); if(ni.primeFactor > d1i.primeFactor + d2i.primeFactor)return 0; long num = ni.value; long denom = modPow(d1i.value*d2i.value, MODVAL-2); return (int)((num*denom)%MODVAL); } public static long modPow(long b, long p) { b = b%MODVAL; if(p == 0)return 1; if(p == 1)return b; long a = modPow(b, p/2); a = (a*a)%MODVAL; if(p%2 == 1) a = (a*b)%MODVAL; return a; } public static class FactorialInfo { final static long pow1 = factorials[MODVAL-1]; final static long pow2 = modPow(pow1, MODVAL+1); long primeFactor; long value; public FactorialInfo(long n) { long b2 = n/((long)MODVAL*(long)MODVAL); n -= b2*(long)MODVAL*(long)MODVAL; long b1 = n/MODVAL; n -= b1*MODVAL; primeFactor = b1 + b2*(MODVAL+1); value = factorials[(int)n]; value *= modPow(pow1, b1)*factorials[(int)b1]; value %= MODVAL; value *= modPow(pow2, b2)*factorials[(int)b2]; value %= MODVAL; } } }