//
//  main.cpp
//  TheLovers
//
//  Created by Dinesh Dommaraju on 10/4/14.
//  Copyright (c) 2014 RIT. All rights reserved.
//

#include <iostream>
using namespace std;
#define N 100010
long long fac[N];

long long pow(int a,int x,int p)
{
    if(x==0) return 1;
    long long res=pow(a,x/2,p);
    res=(res*res)%p;
    if(x%2!=0)res*=a;
    res%=p;
    return res;
}

long long compute_ncr(long long n,long long r,long long p)
{
    long long re = 1;
    while(n && r)
    {
        long long tempN = n%p;
        long long tempR = r%p;
        if(tempN < tempR)
        {
            return 0;
        }
        re = re*fac[int(tempN)]*pow(fac[(int)tempR]*fac[(int)(tempN-tempR)]%p,p-2,p)%p;//
        n /= p;
        r /= p;
    }
    return re;
}

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        long long n,r,p;
        p=100003;
        cin >> n >> r;
        fac[0] = 1;
        for(int i = 1;i <= p;i++)
            fac[i] = fac[i-1]*i%p;
        cout << compute_ncr(n-r+1,r,p) << "\n";
    }
    return 0;
}