# Enter your code here. Read input from STDIN. Print output to STDOUT
import math
def toDigits(n, b):
    """Convert a positive number n to its digit representation in base b."""
    digits = []
    while n > 0:
        digits.insert(0, n % b)
        n  = n // b
    return digits

def fromDigits(digits, b):
    """Compute the number given by digits in base b."""
    n = 0
    for d in digits:
        n = b * n + d
    return n

def nCr(n,r):
    f = math.factorial
    if n<r:
        return 0
    return f(n) / f(r) / f(n-r)

numCases = int(raw_input())

for x in xrange(0,numCases):
    inputt = raw_input()
    n = int(inputt.split(" ")[0])
    r = int(inputt.split(" ")[1])
    nSpec = toDigits(n-r+1,100003)
    rSpec = toDigits(r,100003)
    ans = 1
    for z in xrange(0,len(nSpec)):
        ans*=nCr(nSpec[z],rSpec[z])
    print ans % 100003