import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
	/*position i, j*/
	//return the product from i to j, mod 100003

	public static long fac_mod(long i, long j) {
			long result = 0;
			if ((j-i)<=1) {
				j = j%100003;
				i = i%100003;
				long product = j*i;
				result = (product%100003);
			}
			else {
				long mid = (i+j)/2;
				long a = fac_mod(i, mid);
				long b =  fac_mod(mid+1, i);
				result = (a*b % 100003);
			}
			return result;
	}

	public static long output(long n, long k) {
			long result;
			long j = n-k;
			if (j<k) result = 0;
			else if (j==k) result = ((k+1) % 100003);
			else result = fac_mod(k+1, j+1)/2;
			return result;
	}

    public static void main(String[] args) {
	    	Scanner sc = new Scanner(System.in);
	    	int n = sc.nextInt();
	    	long[] list = new long[n];

	    	for (int i = 0; i<n; i++) {

	    		long a = sc.nextLong();
	    		long b = sc.nextLong();
	    		list[i] = output(a, b);
	    	}

	    	for (int i = 0; i<n; i++) {
	    		System.out.println(list[i]);
	    	}
	    	/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
	}
}