#include <iostream>
#include <cassert>
using namespace std;

const int64_t mod = 100003;
// const int64_t mod = 3;
int64_t fact[mod + 1];
int64_t inv[mod + 1];

void check(int64_t n) {
    assert(n >= 0 && n < mod);
}

int64_t pow(int64_t x, int64_t n) {
    if (n == 0) {
        return 1;
    }

    int64_t h = pow(x, n/2);
    h = ( h * h ) % mod;
    if (n & 1) {
        h = (h * x) % mod;
    }
    return h;
}

int64_t factorial(int64_t N) {
    if (N == 0) {
        return 1;
    }

    int64_t f = N / mod;
    int64_t ret = pow(fact[mod - 1], f);
    ret = (ret * fact[N % mod]) % mod;

    int64_t rr = factorial(N / mod);
    ret = (ret * rr) % mod;
    return ret;
}

int64_t divForLife(int64_t n) {
    int64_t res = 0;
    while (n >= mod) {
        res = res + n / mod;
        n /= mod;
    }
    return res;
}

int64_t C(int64_t n, int64_t k) {
    if (k > n) {
        return 0;
    }

    if (k == n) {
        return 1;
    }

    int64_t diff = divForLife(n) - divForLife(n - k) - divForLife(k);
    if (diff > 0) {
        return 0;
    }

    /*
    if (diff < 0) {
        // assert(0);
        // return 0;
    }
    */

    int64_t n1 = factorial(n);
    int64_t d1 = factorial(n - k);
    int64_t d2 = factorial(k);

    check(d1);
    check(d2);
    check(n1);

    d1 = (d1 * d2) % mod;
    check(d1);
    n1 = (n1 * inv[d1]) % mod;
    check(n1);
    return n1;
}


int main() {
    fact[0] = fact[1] = inv[1] = 1;
    for (int i = 2; i < mod; i++) {
        fact[i] = (fact[i-1] * i) % mod;
        inv[i] = pow(i, mod - 2);
    }

    int T;
    int64_t N, K;
    cin >> T;
    while (T --) {
        cin >> N >> K;
        int64_t num = N - K + 1;
        int64_t den = K;
        cout << C(num, den) << endl;
    }
}