#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 */
int getNumWalkoverMatch(int, int *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int T, level, quitPlayer[(1 << 10)], numQuit, i;
  scanf("%d", &T);
  while (T) {
    scanf("%d %d", &level, &numQuit);
    for (i = 0; i < numQuit; i++) {
      scanf("%d", &quitPlayer[i]);
      quitPlayer[i]--;
    }
    printf("%d\n", getNumWalkoverMatch(level, quitPlayer, numQuit));
    T--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1213 <main+0xe3>
lea    0xe9b(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x1014(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x1018(%rbp)
mov    -0x1018(%rbp),%eax
cmp    -0x1014(%rbp),%eax
jge    11e2 <main+0xb2>
movslq -0x1018(%rbp),%rax
lea    -0x1010(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movslq -0x1018(%rbp),%rax
mov    -0x1010(%rbp,%rax,4),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1010(%rbp,%rax,4)
mov    -0x1018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1018(%rbp)
jmp    1181 <main+0x51>
mov    -0xc(%rbp),%edi
lea    -0x1010(%rbp),%rsi
mov    -0x1014(%rbp),%edx
call   1030 <getNumWalkoverMatch@plt>
mov    %eax,%esi
lea    0xe06(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x24>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
lea    0xebb(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
je     11f6 <main+0xc6>
lea    0x4(%rsp),%r12
lea    0x10(%rsp),%r14
lea    0xe93(%rip),%rbx
lea    0xe8f(%rip),%rbp
jmp    119d <main+0x6d>
nopl   0x0(%rax)
mov    0xc(%rsp),%edi
mov    %r14,%rsi
call   1030 <getNumWalkoverMatch@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
addl   $0xffffffff,0x8(%rsp)
je     11f6 <main+0xc6>
lea    0xe5c(%rip),%rdi
lea    0xc(%rsp),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%edx
test   %edx,%edx
jle    1180 <main+0x50>
mov    %r14,%r13
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
addl   $0xffffffff,0x0(%r13)
add    $0x1,%r15
movslq 0x4(%rsp),%rdx
add    $0x4,%r13
cmp    %rdx,%r15
jl     11d0 <main+0xa0>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i32]
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast [1024 x i32]* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 0
br i1 %11, label %36, label %12
12: ; preds = %0
%13 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 0
br label %14
14: ; preds = %12, %28
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %4)
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %14, %18
%19 = phi i64 [ %24, %18 ], [ 0, %14 ]
%20 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 %19
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %20)
%22 = load i32, i32* %20
%23 = add nsw i32 %22, -1
store i32 %23, i32* %20
%24 = add nuw nsw i64 %19, 1
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %18, label %28
28: ; preds = %18, %14
%29 = phi i32 [ %16, %14 ], [ %25, %18 ]
%30 = load i32, i32* %2
%31 = call i32 @getNumWalkoverMatch(i32 %30, i32* %13, i32 %29)
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %1
%34 = add nsw i32 %33, -1
store i32 %34, i32* %1
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %14
36: ; preds = %28, %0
ret i32 0
}