using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Numerics;
class Solution {
    static void Main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
        int N = Convert.ToInt32(Console.ReadLine());
            string[] str = new string[N];
            for (int i = 0; i < N; i++)
            {
                str[i] = Console.ReadLine().ToString();
            }
            List<BigInteger> output = new List<BigInteger>();

            foreach (var item in str)
            {
                BigInteger[] myInts = Array.ConvertAll(item.Split(' '), s => BigInteger.Parse(s));
               BigInteger i = myInts[0] - myInts[1] + 1;
               if (i >= myInts[1])
               {
                   Console.WriteLine(Combination(i, myInts[1]));
               }
               else
               {
                   Console.WriteLine(0);
               }
            }
    }
        private static BigInteger Combination(BigInteger numberupper,BigInteger numberlower)
        {
            BigInteger mult1 = 1;
            for (BigInteger i = numberupper; i > numberupper-numberlower; i--)
            {
                mult1 = mult1 * i;
            }
            BigInteger mult2 = 1;
            for (BigInteger i = 1; i <= numberlower; i++)
            {
                mult2 = mult2 * i;
            }
            return ((mult1/mult2) % 100003);
        }
}