# Enter your code here. Read input from STDIN. Print output to STDOUTuse 5.18.2;
use warnings;
use Math::BigInt;


my $numOfLines = <STDIN>;
my @ans;

foreach(1..$numOfLines){
	my $point = <STDIN>;
	chomp $point;
	my @coord = $point =~ /(-?\d+)/g;
	&func(@coord);
}

foreach (@ans){
	print "$_\n";

}


sub func{
	my ($N, $K) = @_;
	
	my $top = $N - $K + 1;
	#print "top:\t$top\n";
	
	my $ans = &Choose($top, $K);
	
	push @ans, $ans;
	
}


sub combination{
	my $top = Math::BigInt->new($_[0]);
	my $bottom = Math::BigInt->new($_[1]);
	my $diff = $top - $bottom;
	
	$top = $top->bfac();
	$diff = $diff->bfac();
	$bottom = $bottom->bfac();
	
	return ((($top)/($diff*$bottom)) % 100003);
	
}

sub Choose {
  my $n = shift;  die "N ($n) must be a positive integer" if $n < 1;
  my $r = shift;
  my $f = shift || '';


  # SUMMATION ACROSS R ---------------------------------------------
  if ($r eq '*') { 

    # NO REPETITION
    if (!$f) {
      return 1 << $n

    # REPETITION
    } elsif ($f eq 'r') {
      my $sum = 0;
      for my $r (0..$n) {
        my $c = Math::BigInt->new(1);
        for (1..$r) {          
          $c *= $n + $_ - 1;            # n! / (n-r)!
          $c /= $_;                     # c  / r!
        }
        $sum += $c;
      }
      return $sum;

    # INVALID FLAG
    } else {
      die "Invalid Flag: '$f'"
    }

  # SPECIFIED R ----------------------------------------------------
  } else {

    # NO REPETITION
    if (!$f) {
      return 0
          if ($r < 0 || $r > $n);
      my $c = Math::BigInt->new(1);
      if ($r > $n/2) { $r = $n - $r }   # Take advantage of 2)
      for (1..$r) {
        $c *= $n--;                     # n! / (n-r)!
        $c /= $_;                       # c  / r!
      }
      return ($c % 100003);

    # REPETITION
    } elsif ($f eq 'r') {
      die "R ($r) must be 0 < R if there is repetition" if ($r < 0);
      $n += $r - 1;
      my $c = 1;
      if ($r > $n/2) { $r = $n - $r }   # Take advantage of 2)
      for (1..$r) {
        $c *= $n--;                     # n! / (n-r)!
        $c /= $_;                       # c  / r!
      }
      return $c;
      
    # INVALID FLAG
    } else {
      die "Invalid Flag: '$f'"
    }
  }
}