#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 */
unsigned long long fact(unsigned long);
int /*<<< orphan*/ printf(char *, unsigned long long);
int /*<<< orphan*/ scanf(char *, unsigned long *);
int main() {
  unsigned long n = 0, m = 0, test = 0;
  unsigned long long num = 0, den = 0, result = 0, mod = 1000000007;
  scanf("%lu", &test);
  while (test != 0) {
    scanf("%lu", &n);
    scanf("%lu", &m);
    num = fact(n + m - 1);
    den = fact(n) * fact(m - 1);
    printf("%llu", den);
    result = ((unsigned long long)num / den);
    printf("%llu\n", result % mod);
    --test;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x3b9aca07,-0x40(%rbp)
3b
lea    0xe82(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
cmpq   $0x0,-0x20(%rbp)
je     123c <main+0x10c>
lea    0xe67(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe57(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
sub    $0x1,%rdi
call   1040 <fact@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fact@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
sub    $0x1,%rdi
call   1040 <fact@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x30(%rbp)
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x40(%rbp)
mov    %rdx,%rsi
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1187 <main+0x57>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xea1(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
cmpq   $0x0,(%rsp)
je     1245 <main+0x115>
lea    0xe87(%rip),%rbx
movabs $0x89705f3112a28fe5,%r12
5f 70 89
lea    0xe7f(%rip),%r13
jmp    11c2 <main+0x92>
nopl   0x0(%rax)
mov    %rbp,%rax
xor    %edx,%edx
div    %r14
mov    %rax,%rsi
mov    %rsi,%rax
mul    %r12
shr    $0x1d,%rdx
imul   $0x3b9aca07,%rdx,%rax
sub    %rax,%rsi
mov    %r13,%rdi
call   1030 <printf@plt>
addq   $0xffffffffffffffff,(%rsp)
je     1245 <main+0x115>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%rcx
lea    (%rax,%rcx,1),%rdi
add    $0xffffffffffffffff,%rdi
call   1040 <fact@plt>
mov    %rax,%rbp
mov    0x10(%rsp),%rdi
call   1040 <fact@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rdi
add    $0xffffffffffffffff,%rdi
call   1040 <fact@plt>
mov    %rax,%r14
imul   %r15,%r14
lea    0xde5(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %rbp,%rax
or     %r14,%rax
shr    $0x20,%rax
jne    1190 <main+0x60>
mov    %ebp,%eax
xor    %edx,%edx
div    %r14d
mov    %eax,%esi
jmp    119b <main+0x6b>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lu\00"
@.str.1 = [5 x i8] c"%llu\00"
@.str.2 = [6 x i8] c"%llu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
store i64 0, i64* %3
store i64 0, i64* %4
store i64 0, i64* %5
store i64 0, i64* %6
store i64 0, i64* %7
store i64 1000000007, i64* %8
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %4)
br label %10
10: ; preds = %13, %0
%11 = load i64, i64* %4
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %38
13: ; preds = %10
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
%16 = load i64, i64* %2
%17 = load i64, i64* %3
%18 = add i64 %16, %17
%19 = sub i64 %18, 1
%20 = call i64 @fact(i64 %19)
store i64 %20, i64* %5
%21 = load i64, i64* %2
%22 = call i64 @fact(i64 %21)
%23 = load i64, i64* %3
%24 = sub i64 %23, 1
%25 = call i64 @fact(i64 %24)
%26 = mul i64 %22, %25
store i64 %26, i64* %6
%27 = load i64, i64* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %27)
%29 = load i64, i64* %5
%30 = load i64, i64* %6
%31 = udiv i64 %29, %30
store i64 %31, i64* %7
%32 = load i64, i64* %7
%33 = load i64, i64* %8
%34 = urem i64 %32, %33
%35 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %34)
%36 = load i64, i64* %4
%37 = add i64 %36, -1
store i64 %37, i64* %4
br label %10
38: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lu\00"
@.str.1 = [5 x i8] c"%llu\00"
@.str.2 = [6 x i8] c"%llu\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%5 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
%8 = load i64, i64* %3
%9 = icmp eq i64 %8, 0
br i1 %9, label %31, label %10
10: ; preds = %0, %10
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%13 = load i64, i64* %1
%14 = load i64, i64* %2
%15 = add i64 %13, -1
%16 = add i64 %15, %14
%17 = call i64 @fact(i64 %16)
%18 = load i64, i64* %1
%19 = call i64 @fact(i64 %18)
%20 = load i64, i64* %2
%21 = add i64 %20, -1
%22 = call i64 @fact(i64 %21)
%23 = mul i64 %22, %19
%24 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %23)
%25 = udiv i64 %17, %23
%26 = urem i64 %25, 1000000007
%27 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %26)
%28 = load i64, i64* %3
%29 = add i64 %28, -1
store i64 %29, i64* %3
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %10
31: ; preds = %10, %0
ret i32 0
}