#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
long long ncr(long long, long long);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, long long *);
int main() {
  long long int n, r, t, i;
  scanf("%lld", &t);
  while (t != 0) {
    scanf("%lld", &n);
    scanf("%lld", &r);
    n = n - r;
    r--;
    long long int ans = ncr(n + r, n);
    printf("%lld\n", ans);
    t--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x0,-0x20(%rbp)
je     11c8 <main+0x98>
lea    0xe9f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe8f(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
sub    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <ncr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebe(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
cmpq   $0x0,(%rsp)
je     11bf <main+0x8f>
lea    0xea8(%rip),%rbx
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r15
lea    0xe9c(%rip),%r12
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rax
mov    %rdi,%rsi
sub    %rax,%rsi
mov    %rsi,0x10(%rsp)
add    $0xffffffffffffffff,%rax
mov    %rax,0x8(%rsp)
add    $0xffffffffffffffff,%rdi
call   1050 <ncr@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
addq   $0xffffffffffffffff,(%rsp)
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %4)
br label %8
8: ; preds = %11, %0
%9 = load i64, i64* %4
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %28
11: ; preds = %8
%12 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%13 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
%14 = load i64, i64* %2
%15 = load i64, i64* %3
%16 = sub nsw i64 %14, %15
store i64 %16, i64* %2
%17 = load i64, i64* %3
%18 = add nsw i64 %17, -1
store i64 %18, i64* %3
%19 = load i64, i64* %2
%20 = load i64, i64* %3
%21 = add nsw i64 %19, %20
%22 = load i64, i64* %2
%23 = call i64 @ncr(i64 %21, i64 %22)
store i64 %23, i64* %6
%24 = load i64, i64* %6
%25 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %24)
%26 = load i64, i64* %4
%27 = add nsw i64 %26, -1
store i64 %27, i64* %4
br label %8
28: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
%8 = load i64, i64* %3
%9 = icmp eq i64 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %0, %10
%11 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%12 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%13 = load i64, i64* %1
%14 = load i64, i64* %2
%15 = sub nsw i64 %13, %14
store i64 %15, i64* %1
%16 = add nsw i64 %14, -1
store i64 %16, i64* %2
%17 = add i64 %13, -1
%18 = call i64 @ncr(i64 %17, i64 %15)
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %18)
%20 = load i64, i64* %3
%21 = add nsw i64 %20, -1
store i64 %21, i64* %3
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %10
23: ; preds = %10, %0
ret i32 0
}