import java.util.*;
import java.lang.*;

public class hacker5 {
	static int p = 100003;
	//static int p = 16;
	
	static Scanner scan = new Scanner(System.in);
	
	private static int calc(long n, long k){

		long ans = 1;
		if (n < k) {
			System.out.println(0);
			return 0;
		}
		while(n > 0){
			
		long x = n%p;
		long y = k%p;
		//System.out.println("AAAAAA "+n + " " + x);
		//System.out.println(n%p);
		ans *= choose(x,y) % p;
		ans %= p;
		n /= p;
		k /= p;
		}
		
		System.out.println(ans);
		return 0;
	}
	
	private static int choose(long x, long y){
		if (y == 0) return 1;
		if(x < y) return 0;
		long facx = 1;
		for(int i = 1; i <= x; i++){
			facx = (facx * i) % p;
		}
		
		long facy = 1;
		for(int i = 1; i <= y; i++){
			facy = (facy * i) % p;
		}
		for(int i = 1; i <= x - y; i++){
			facy = (facy * i) % p;
		}
		
		int c = -1;
		
		for(int i = 0; i < p; i++){
			if((facy * i - facx) % p == 0) {
				c = i;
				break;
			}
		}
		
		//System.out.println(facx+ " " + facy + " "+c);
		return c;
	}
	
	private static void solve(){
		long n = scan.nextLong();
		long k = scan.nextLong();
		
		//calculate c(n-k+1) - k
		calc(n-k+1, k);
		
	}
	
	private static void solveProblem(){
		
		
		int t = scan.nextInt();
		//int answer = 0;
		
		for(int i = 0; i < t; i++){
			solve();
		}
		
		//System.out.println(answer);
		return ;
	}

	
	public static void main(String[] args) {
		solveProblem();	
	}
}