object Solution {
    def factorial(n:BigInt, k : BigInt):BigInt = {
            var origN : BigInt = n
            var temp1 : BigInt = 1
            var temp2 : BigInt = 1
            if (n==0) 
                return 1 
            else {
                if(n==k){
                    return temp2;
                }
                else{
                    temp2 = (n * factorial(n-1, k))
                }
                return temp2;
            }
                
                }
    def calculate_combinations (N : BigInt , K : BigInt): BigInt = {
        var n = N;
        var k = K;
        var temp1 : Double = Math.ceil(n.toDouble / 2);
        var temp2 : Double = k.toDouble;
        //println(N, K , temp1, temp2)
        if(temp2 > temp1){
          //print("Zero Case")
            return 0;
        }
        else{
            return ((factorial(N-K+1, N-K+1-K ))/(factorial(K , 1))) % 100003
            /*if(temp2 == temp1){
                
                println("Equal Case", K , N/2)
                //println(factorial(N-K+1));
                //println(factorial(N-K+1-K) * factorial(K));
                return ((factorial(N-K+1))/(factorial(N-K+1-K) * factorial(K)))
            }
            else
            {
                println("Here")
                //return 0;
                 return ((factorial(N-K+1))/(factorial(N-K+1-K) * factorial(K)))   
                //return ((factorial(N-2))/(factorial(N-2-K) * factorial(K)))
            }*/
        }
    }
    def main(args: Array[String]) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution
*/      
        var total=readLine()
        var test = total.toInt
            for(i <- 0 until test) {
                var input=readLine()
                var In : Array[Int]= input.split(" ").map( _.toInt )
               // println(In(0),In(1));
                println(calculate_combinations(In(0),In(1)));
            }
        /*println(calculate_combinations(7,3));
        println(calculate_combinations(8,5));
        println(calculate_combinations(10,5));
        println(calculate_combinations(100000,555));*/
    }
        
}