#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 /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, int *);
int solutions(int, char *);
int main() {
  int n, h;
  char holes[144];
  while (1) {
    scanf("%d %d", &n, &h);
    if (!n && !h)
      break;
    memset(holes, 0, 144 * sizeof(char));
    while (h--) {
      int r, c;
      scanf("%d %d", &r, &c);
      holes[r * n + c] = 1;
    }
    printf("%d\n", solutions(n, holes));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    117f <main+0x3f>
cmpl   $0x0,-0xc(%rbp)
jne    117f <main+0x3f>
jmp    1201 <main+0xc1>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x90,%edx
call   1050 <memset@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     11df <main+0x9f>
lea    0xe53(%rip),%rdi
lea    -0xa4(%rbp),%rsi
lea    -0xa8(%rbp),%rdx
call   1060 <scanf@plt>
mov    -0xa4(%rbp),%eax
imul   -0x8(%rbp),%eax
add    -0xa8(%rbp),%eax
cltq
movb   $0x1,-0xa0(%rbp,%rax,1)
01
jmp    1192 <main+0x52>
mov    -0x8(%rbp),%edi
lea    -0xa0(%rbp),%rsi
call   1040 <solutions@plt>
mov    %eax,%esi
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
jmp    1152 <main+0x12>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
lea    0xea8(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
or     (%rsp),%eax
je     1221 <main+0xe1>
lea    0x10(%rsp),%r15
lea    0xe82(%rip),%rbx
lea    0x4(%rsp),%r12
mov    %rsp,%r13
lea    0xc(%rsp),%rbp
lea    0x8(%rsp),%r14
jmp    11d1 <main+0x91>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
mov    %r15,%rsi
call   1040 <solutions@plt>
lea    0xe53(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
or     (%rsp),%eax
je     1221 <main+0xe1>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x90,%edx
call   1050 <memset@plt>
subl   $0x1,(%rsp)
jb     11a0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1060 <scanf@plt>
movslq 0xc(%rsp),%rax
movslq 0x4(%rsp),%rdi
imul   %rdi,%rax
movslq 0x8(%rsp),%rcx
add    %rax,%rcx
movb   $0x1,0x10(%rsp,%rcx,1)
subl   $0x1,(%rsp)
jae    11f0 <main+0xb0>
jmp    11a4 <main+0x64>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [144 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = getelementptr inbounds [144 x i8], [144 x i8]* %3, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%10 = load i32, i32* %1
%11 = icmp ne i32 %10, 0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %15, label %47
15: ; preds = %0
%16 = bitcast i32* %4 to i8*
%17 = bitcast i32* %5 to i8*
br label %18
18: ; preds = %15, %37
%19 = call i32 @memset(i8* %8, i32 0, i32 144)
%20 = load i32, i32* %2
%21 = add nsw i32 %20, -1
store i32 %21, i32* %2
%22 = icmp eq i32 %20, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = load i32, i32* %1
br label %37
25: ; preds = %18, %25
%26 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%27 = load i32, i32* %4
%28 = load i32, i32* %1
%29 = mul nsw i32 %28, %27
%30 = load i32, i32* %5
%31 = add nsw i32 %29, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [144 x i8], [144 x i8]* %3, i64 0, i64 %32
store i8 1, i8* %33
%34 = load i32, i32* %2
%35 = add nsw i32 %34, -1
store i32 %35, i32* %2
%36 = icmp eq i32 %34, 0
br i1 %36, label %37, label %25
37: ; preds = %25, %23
%38 = phi i32 [ %24, %23 ], [ %28, %25 ]
%39 = call i32 @solutions(i32 %38, i8* %8)
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%42 = load i32, i32* %1
%43 = icmp ne i32 %42, 0
%44 = load i32, i32* %2
%45 = icmp ne i32 %44, 0
%46 = select i1 %43, i1 true, i1 %45
br i1 %46, label %18, label %47
47: ; preds = %37, %0
ret i32 0
}