#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int numV, u;
  while (1) {
    scanf("%d", &numV);
    if (numV == 0)
      break;
    if (numV == 2 || (numV & 1))
      printf("Impossible\n");
    else {
      printf("%d\n", (3 * numV) >> 1);
      for (u = 1; u <= numV; u += 2) {
        printf("%d %d\n", u, u + 1);
        if (u > 1)
          printf("%d %d\n", u, u - 1);
        if (u < numV - 1)
          printf("%d %d\n", u, u + 3);
      }
      printf("%d %d\n", 1, numV - 1);
      printf("%d %d\n", 2, numV);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    114e <main+0x2e>
jmp    1249 <main+0x129>
cmpl   $0x2,-0x8(%rbp)
je     1167 <main+0x47>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     117a <main+0x5a>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <main+0x124>
imul   $0x3,-0x8(%rbp),%esi
sar    $0x1,%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1215 <main+0xf5>
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jle    11da <main+0xba>
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1202 <main+0xe2>
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
add    $0x3,%edx
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1207 <main+0xe7>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x76>
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
lea    0xded(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edx
lea    0xdd7(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%r14
lea    0x4(%rsp),%r13
lea    0xebc(%rip),%r15
lea    0xeb1(%rip),%r12
lea    0xea7(%rip),%rbx
jmp    1168 <main+0x38>
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     1160 <main+0x30>
test   %eax,%eax
je     1265 <main+0x135>
test   $0x1,%al
jne    1160 <main+0x30>
lea    (%rax,%rax,2),%esi
sar    %esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
test   %edx,%edx
jle    11e0 <main+0xb0>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
cmp    $0x3,%edx
jl     11e0 <main+0xb0>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
cmp    $0x3,%edx
jge    120a <main+0xda>
nopl   0x0(%rax)
add    $0xffffffff,%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1168 <main+0x38>
mov    $0x3,%ebp
jmp    1227 <main+0xf7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x2,%ebp
cmp    %edx,%ebp
jg     11e0 <main+0xb0>
lea    0x1(%rbp),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%rbp),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
lea    -0x1(%rdx),%eax
cmp    %eax,%ebp
jge    1220 <main+0xf0>
lea    0x3(%rbp),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
jmp    1220 <main+0xf0>
xor    %eax,%eax
add    $0x8,%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 = [12 x i8] c"Impossible\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %0, %59
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %4
br label %60
9: ; preds = %4
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 2
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = and i32 %13, 1
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12, %9
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %59
18: ; preds = %12
%19 = load i32, i32* %2
%20 = mul nsw i32 3, %19
%21 = ashr i32 %20, 1
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
store i32 1, i32* %3
br label %23
23: ; preds = %50, %18
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %53
27: ; preds = %23
%28 = load i32, i32* %3
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %30)
%32 = load i32, i32* %3
%33 = icmp sgt i32 %32, 1
br i1 %33, label %34, label %39
34: ; preds = %27
%35 = load i32, i32* %3
%36 = load i32, i32* %3
%37 = sub nsw i32 %36, 1
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %37)
br label %39
39: ; preds = %34, %27
%40 = load i32, i32* %3
%41 = load i32, i32* %2
%42 = sub nsw i32 %41, 1
%43 = icmp slt i32 %40, %42
br i1 %43, label %44, label %49
44: ; preds = %39
%45 = load i32, i32* %3
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 3
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %45, i32 %47)
br label %49
49: ; preds = %44, %39
br label %50
50: ; preds = %49
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 2
store i32 %52, i32* %3
br label %23
53: ; preds = %23
%54 = load i32, i32* %2
%55 = sub nsw i32 %54, 1
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %55)
%57 = load i32, i32* %2
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %57)
br label %59
59: ; preds = %53, %16
br label %4
60: ; preds = %8
ret i32 0
}

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