PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000145. Đồ thị nguyên tố (Prime Graph)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đồ thị nguyên tố (Prime Graph)

Prime Graph

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Construct an undirected simple graph on exactly nn vertices, with a prime number of edges and prime degree at every vertex. The graph need not be connected. Output -1 if impossible, otherwise any valid graph.

Input

A line containing nn.

Output

Print mm followed by mm edges, or -1.

Subtask

  • Subtask 1 (20 points): 3≤n≤203\le n\le20.
  • Subtask 2 (30 points): 3≤n≤2003\le n\le200.
  • Subtask 3 (50 points): 3≤n≤10003\le n\le1000.

Example

Input

4

Output

5
1 2
2 3
3 4
4 1
1 3

Explanation

There are five edges, a prime number; vertex degrees are 3,2,3,23,2,3,2, all prime. The graph is simple.