Every person likes prime numbers. Alice is a person, thus she also shares the love for them. Bob wanted to give her an affectionate gift but couldn't think of anything inventive. Hence, he will be giving her a graph. How original, Bob! Alice will surely be thrilled!

When building the graph, he needs four conditions to be satisfied:   It must be a simple undirected graph, i.e. without multiple (parallel) edges and self-loops.  The number of vertices must be exactly $n$ — a number he selected. This number is not necessarily prime.  The total number of edges must be prime.  The degree (i.e. the number of edges connected to the vertex) of each vertex must be prime. 

Below is an example for $n = 4$. The first graph (left one) is invalid as the degree of vertex $2$ (and $4$) equals to $1$, which is not prime. The second graph (middle one) is invalid as the total number of edges is $4$, which is not a prime number. The third graph (right one) is a valid answer for $n = 4$.  [Image] 

Note that the graph can be disconnected.

Please help Bob to find any such graph!


-----Input-----

The input consists of a single integer $n$ ($3 \leq n \leq 1\,000$) — the number of vertices.


-----Output-----

If there is no graph satisfying the conditions, print a single line containing the integer $-1$.

Otherwise, first print a line containing a prime number $m$ ($2 \leq m \leq \frac{n(n-1)}{2}$) — the number of edges in the graph. Then, print $m$ lines, the $i$-th of which containing two integers $u_i$, $v_i$ ($1 \leq u_i, v_i \leq n$) — meaning that there is an edge between vertices $u_i$ and $v_i$. The degree of each vertex must be prime. There must be no multiple (parallel) edges or self-loops.

If there are multiple solutions, you may print any of them.

Note that the graph can be disconnected.


-----Examples-----
Input
4

Output
5
1 2
1 3
2 3
2 4
3 4
Input
8

Output
13
1 2
1 3
2 3
1 4
2 4
1 5
2 5
1 6
2 6
1 7
1 8
5 8
7 8



-----Note-----

The first example was described in the statement.

In the second example, the degrees of vertices are $[7, 5, 2, 2, 3, 2, 2, 3]$. Each of these numbers is prime. Additionally, the number of edges, $13$, is also a prime number, hence both conditions are satisfied. [Image]

Difficulty: interview

Starter code:

Solutions:
n = int(input())

def pr(x):
	for i in range(2, x):
		if x % i == 0:
			return False
	return True

e = []
for i in range(n):
	e += [[i, (i+1) % n]]
x = n
u = 0
v = n // 2
while not pr(x):
	e += [[u, v]]
	x += 1
	u += 1
	v += 1

print(x)
for g in e:
	print(g[0]+1, g[1]+1)

import math, sys

def isprime(x):
    for d in range(2, int(math.sqrt(x)) + 1):
        if x % d == 0:
            return False
    return True

n = int(input())

edges = []
for x in range(n):
    edges.append((x, (x + 1) % n))

m = n
i = 0
while not isprime(m):
    edges.append((i, n - 2 - i))
    i += 1
    m += 1

print(m)
for u, v in edges:
    print(u + 1, v + 1)




M = 10**5 + 2
prime = [0]*M
for i in range(2, M):
    if prime[i]:
        continue
    for j in range(i, M, i):
        if not prime[j]:
            prime[j] = i

N = int(input())

Edge = [(i, i+1) for i in range(1, N)] + [(1, N)]

D = N
Nh = N//2
cnt = 1
while prime[D] != D:
    D += 1
    Edge.append((cnt, cnt+Nh))
    cnt += 1
print(len(Edge))
for e in Edge:
    print(*e)


n = int(input())
p = set([2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021])
out = []
curr = 0
for i in range(n):
    curr += 1
    out.append((i,(i+1)%n))
num = 0
while curr not in p:
    out.append(((num)%n,(num+2)%n))
    num += 1
    curr += 1
    if num % 4 == 2:
        num += 2
    
print(curr)
for (a,b) in out:
    print(a+1,b+1)


primes = [2,   3,   5,   7,  11,  13,  17,  19,  23,  29,  31,  37,  41,
  43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97, 101,

 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,

 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313,
 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397,

 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467,
 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569,

 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643,
 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733,

 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823,
 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911,

 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009]

vertices = int(input())

edges = []
for i in range(2, vertices + 1):
    edges.append([i-1, i])
edges.append([vertices, 1])

lenEdges = len(edges)
i = 2
j = vertices
while lenEdges not in primes and i < j:
    edges.append([i, j])
    i += 1
    j -= 1
    lenEdges += 1

print(lenEdges)
for edge in edges:
    print(*edge)


import sys


n = int(sys.stdin.readline().strip())
P = []
i = 2
v = True
while v == True:
    w = True
    for p in P:
        if i % p == 0:
            w = False
    if w == True:
        P.append(i)
        if i >= n:
            v = False
            e = i
    i = i + 1

E = [[1,n]]
for i in range (0, n-1):
    E.append([i+1, i+2])
m = n
i = 0
while e > m:
    E.append([i+1, i+1+n//2])
    m = m + 1
    i = i+ 1

print(len(E))
for i in range (0, len(E)):
    print(str(E[i][0]) + " " + str(E[i][1]))

import sys
input = sys.stdin.readline

n=int(input())
A={2, 3, 5, 7, 521, 11, 523, 13, 17, 19, 23, 29, 541, 31, 547, 37, 41, 43, 557, 47, 563, 53, 569, 59, 571, 61, 577, 67, 71, 73, 587, 79, 593, 83, 599, 89, 601, 607, 97, 101, 613, 103, 617, 107, 619, 109, 113, 631, 127, 641, 131, 643, 647, 137, 139, 653, 659, 149, 661, 151, 157, 673, 163, 677, 167, 683, 173, 179, 691, 181, 701, 191, 193, 197, 709, 199, 719, 211, 727, 733, 223, 227, 739, 229, 743, 233, 239, 751, 241, 757, 761, 251, 257, 769, 773, 263, 269, 271, 787, 277, 281, 283, 797, 293, 809, 811, 307, 821, 311, 823, 313, 827, 317, 829, 839, 331, 337, 853, 857, 347, 859, 349, 863, 353, 359, 877, 367, 881, 883, 373, 887, 379, 383, 389, 907, 397, 911, 401, 919, 409, 929, 419, 421, 937, 941, 431, 433, 947, 439, 953, 443, 449, 967, 457, 971, 461, 463, 977, 467, 983, 479, 991, 997, 487, 491, 499, 503, 509,1009}


p=n
while not(p in A):
    p+=1

print(p)
print(1,n)
for i in range(1,n):
    print(i,i+1)

for j in range(p-n):
    print(j+1,n-j-1)


3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def is_prime(a):
    x = 2
    while x * x <= a:
        if a % x == 0:
            return False
        x += 1
    return True


def main():
    N = int(inp())

    p = N
    while not is_prime(p):
        p += 1

    diff = p - N
    assert diff <= N // 2

    print(p)
    for i in range(N):
        print(i + 1, (i + 1) % N + 1)

    i = 1
    j = 1 + N // 2
    while diff > 0:
        print(i, j)
        i += 1
        j += 1
        diff -= 1


def __starting_point():
    main()

__starting_point()

def primes(n):
    if(n<=2):
        return []
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*int(((n-i*i-1)/(2*i)+1))
    return [2] + [i for i in range(3,n,2) if sieve[i]]
P=primes(2001)


n = int(input())
i = 0
while(P[i] < n):
    i+=1
m = P[i]


toprint = []

for i in range(1, n + 1):
    toprint.append([i, (i) % n + 1])
vis = [False for i in range(n + 1)]
for i in range(1, n + 1):
    if(vis[i]):
        continue
    if(vis[(i + 1)%n + 1]):
        continue
    vis[i] = True
    vis[(i + 1)%n + 1] = True
    toprint.append([i, (i + 1)%n + 1])
print(m)
if(len(toprint) < m):
    print('shit', m, n)
for i in range(m):
    print(*toprint[i])




prime=[True]*1501
prime[0]=False
prime[1]=False
for i in range(2,1501):
	if prime[i]:
		for j in range(i*i,1501,i):
			prime[j]=False
n=int(input())
degree=[2]*n
ans=[]
edges=n
for i in range(n-1):
	ans.append([i+1,i+2])
ans.append([1,n])
c=0
while(not prime[edges]):
	ans.append([c+1,c+n//2+1])
	#print(edges,c,c+n//2)
	degree[c]+=1
	degree[c+n//2]+=1
	c+=1
	edges+=1
print(len(ans))
for i in ans:
	print(i[0],i[1])


import bisect
n = int(input())
def primelist(N):
    prime = [2]
    for i in range(3, N+1):
        flag = 1
        for j in prime:
            if i % j == 0:
                flag = 0
                break
        if flag == 1:
            prime.append(i)
    return prime
prime = primelist(n+100)

ans = []
for i in range(n-1):
    ans.append([i+1, i+2])
ans.append([1, n])

index = bisect.bisect_left(prime, n)
more = prime[index] - n
mid = n//2
for i in range(1, more+1):
    ans.append([i, mid+i])

print(len(ans))
for i in range(len(ans)):
    print(" ".join(map(str, ans[i])))


def make_prime_table(n):
    '''n以下の非負整数が素数であるかを判定するためのリストを出力する
    計算量: O(NloglogN)
    入出力例: 6 -> [False, False, True, True, False, True, False]'''
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(2 * i, n + 1, i):
            is_prime[j] = False
    return is_prime


li = make_prime_table(10000)
n = int(input())
ans = []
for i in range(n-1):
    ans.append((i+1, i+2))
ans.append((i+2, 1))

s = 0
t = n - 2
while not li[len(ans)]:
    ans.append((s+1, t+1))
    s += 1
    t -= 1
print(len(ans))
for i in range(len(ans)):
    print(" ".join(map(str, ans[i])))




import sys
import math
#input = sys.stdin.readline

p=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499]

n=int(input())

arr=[]
for i in range(n-1):
	arr.append([i+1,i+2])
arr.append([1,n])

x=0
while p[x]<n:
	x+=1

d=p[x]-n
for i in range(d):
	arr.append([i+1,n-i-1])

print(len(arr))
for i in range(len(arr)):
	print(*arr[i])


def isp( n ):
    for i in range(2, n):
        if n % i == 0:
            return False
    return True

n = int( input() )
e = [ [ i + 1, ( i + 1 ) % n + 1 ] for i in range( n ) ]
i = 0
while not isp( len( e ) ):
    e.append( [ i + 1, (i + n//2) % n + 1 ] )
    i += 1

print( len( e ) )
for ed in e:
    print( *sorted(ed) )


n = int(input())
odp = []
for i in range(n - 1):
	odp.append([i + 1, i + 2])
odp.append([n, 1])
k = n
def prime(x):
	i = 2
	while i ** 2 <= x:
		if x % i == 0:
			return False
		i += 1
	return True
primes = [0] * 50000
for i in range(50000):
	primes[i] = (1 if prime(i) else 0)
w = (n + 2) // 2
m = 1
while w <= n:
	if primes[k] == 1:
		break
	else:
		odp.append([m, w])
		m += 1
		w += 1
		k += 1
print(len(odp))
for i in range(len(odp)):
	print(odp[i][0], odp[i][1])

n = int(input())
l = [(i,i+1) for i in range(1,n)]
l.append((n,1))
cnt = n
def is_prime(k):
    j = 2
    while j*j <= k:
        if k%j==0:
            return False
        j+=1
    return True
for i in range(1,n-1):
    if is_prime(cnt):
        break
    cnt+=1
    l.append((i,n-i))
print(cnt)
for i in l:
    print(i[0],i[1])

n = int(input())
if n < 3:
    print(-1)
    return
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009]
a = []
for i in range(1000):
    if i % 4 == 1 or i % 4 == 0:
        a.append((i + 1, (i + 2) % n + 1))
m = 0
while primes[m] < n:
    m += 1
m = primes[m]
res = []
for i in range(n):
    res.append((i + 1, (i + 1) % n + 1))
res += a[:max(0, m - n)]
print(len(res))
for i in res:
    print(i[0], i[1])


ll= lambda : list(map(int,input().split()))
testcases=1
prime = []
def seive(n):
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True):
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    return prime
# testcases=int(input())

for testcase in range(testcases):
	prime = seive(2005)
	[n]=ll()
	ii=n
	# print(prime)
	while(prime[ii]!=True):
		ii+=1
	ans=[]
	for i in range(1,n):
		ans.append([i,i+1])
	ans.append([n,1])
	ii-=n
	if ii==0:
		print(len(ans))
		for i in ans:
			print(*i)
		continue
	done=1
	# print(ii)
	while(ii!=0):
		ans.append([done,(done+2)%(n+1)])
		done+=(done&1==0)*2
		done+=1

		ii-=1
	print(len(ans))
	for i in ans:
		print(*i)

n = int(input())
N = n*n

a = [1] * (N + 1)
a[1] = 0
i = 2
while i <= N:
    if a[i] == 1:
        j = 2*i
        while j <= N:
            a[j] = 0
            j += i
    i += 1

k = n
while a[k] == 0:
    k += 1
print(k)
for i in range(1, n + 1):
    if i < n:
        print(i, i + 1)
    if i == n:
        print(i, 1)
now = 1
for i in range(k - n):
    if now + 2 <= n:
        print(now, now + 2)
    else:
        print(now, now + 2 - n)
    if now % 2 == 1:
        now += 1
    else:
        now += 3

from math import sqrt 
n = int(input())
def prost(n):
    for i in range(2, int(sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True

f = n
while not prost(f):
    f += 1
print(f)
for i in range(1, n):
    print(i, i + 1)
print(n, 1)
g = 1
f = f - n
while f:
    print(1 + g - 1, n - g)
    g += 1
    f -= 1


from fractions import gcd
import math


mod = 998244353


primes = list(map(int, "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997 1009 1013 1019 1021 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109 1117 1123 1129 1151 1153 1163 1171 1181 1187 1193 1201 1213 1217 1223 1229 1231 1237 1249 1259 1277 1279 1283 1289 1291 1297 1301 1303 1307 1319 1321 1327 1361 1367 1373 1381 1399 1409 1423 1427 1429 1433 1439 1447 1451 1453 1459 1471 1481 1483 1487 1489 1493 1499 1511 1523 1531 1543 1549 1553 1559 1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 1621 1627 1637 1657 1663 1667 1669 1693 1697 1699 1709 1721 1723 1733 1741 1747 1753 1759 1777 1783 1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889 1901 1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999 2003 2011 2017 2027 2029 2039 2053 2063 2069 2081 2083 2087 2089 2099 2111 2113 2129 2131 2137 2141 2143 2153 2161 2179 2203 2207 2213 2221 2237 2239 2243 2251 2267 2269 2273 2281 2287 2293 2297 2309 2311 2333 2339 2341 2347 2351 2357 2371 2377 2381 2383 2389 2393 2399 2411 2417 2423 2437 2441 2447 2459 2467 2473 2477 2503 2521 2531 2539 2543 2549 2551 2557 2579 2591 2593 2609 2617 2621 2633 2647 2657 2659 2663 2671 2677 2683 2687 2689 2693 2699 2707 2711 2713 2719 2729 2731 2741 2749 2753 2767 2777 2789 2791 2797 2801 2803 2819 2833 2837 2843 2851 2857 2861 2879 2887 2897 2903 2909 2917 2927 2939 2953 2957 2963 2969 2971 2999 ".split()))

def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n = int(input())
    p_idx = usearch(n, primes)
    e = primes[p_idx]
    if e < n:
        e = primes[p_idx+1]
    if n == 3:
        print(3)
        print(1, 2)
        print(2, 3)
        print(3, 1)
        return
    print(e)
    for i in range(n-1):
        print(i+1, i+2)
    print(1, n)

    for i in range(e - n):
        if i % 2 == 0:
            print(i*2+1, i*2+3)
        else:
            print(i*2, i*2+2)

main()






nre       =        int(input())











dpdfdjf       =            []














for i in range(nre    -            1):
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	dpdfdjf.append([ i    +   1,  i + 2])
























dpdfdjf.append([nre  ,   1])














kre             =            nre










def plotttt(xre):













	i                =         2
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	while (i ** 2         <=          xre):
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		if (xre      %        i          ==       0):
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
			return False
		
		
		
		
		
		
		
		
		
		
		
		i        +=            1
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	return True

















plotttts           =          [0]     *      50000


























for i in range(50000):
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	plotttts[i]               =            (1   if  plotttt(i)   else  0)





















wre             =              (nre       +           2) // 2

























mre = 1















while (wre  <=         nre):
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	if (plotttts[kre]                   ==                       1):
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		break
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	else:
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
		
		
		
		dpdfdjf.append([mre ,   wre])
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		mre                   +=                        1
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		wre                    +=                1
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		kre                         +=                1
























print(len(dpdfdjf))






















for i in range(len(dpdfdjf)):
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	print(dpdfdjf[i][0], dpdfdjf[i][1])



from sys import stdin, stdout
import collections
 
N = int(input())
#s = input()
#W,H = [int(x) for x in stdin.readline().split()]
#arr = [int(x) for x in stdin.readline().split()]

def is_prime(a):
    return all(a % i for i in range(2, a))
 
res = N

while not is_prime(res):
    res += 1
    
print(res)
for i in range(N-1):
    print(i+1,i+2)
    
print(N,1)

half = N//2 + 1*(N%2==1)
for i in range(res-N):
    print(i+1,i+1+half)