QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#17947. Chocolate Frog and Stepping Stones

統計

$N$ chocolate frogs are trying to move from Coco Land to Hanbyeol Land. There is a river between Coco Land and Hanbyeol Land, and since chocolate melts when it touches water, they must cross the river using $N$ stepping stones to get from Coco Land to Hanbyeol Land. The stepping stones are numbered $1$ to $N$ in order. For convenience, let the riverbank on the Coco Land side be $0$ and the riverbank on the Hanbyeol Land side be $N+1$.

The chocolate frogs are also numbered $1$ to $N$, and they are stacked at position $0$ in order from $N$ at the bottom to $1$ at the top. Only one frog can move at a time, and if multiple frogs are stacked vertically, only the top frog can move. Furthermore, a frog at position $i$ can only move to position $i+1$ or $i+2$ in a single move, cannot move backward, and a frog with a larger number cannot be placed on top of a frog with a smaller number.

Hanbyeol Land is protected by a barrier, so if the frogs do not enter in descending order of their numbers (from frog $N$ to frog $1$), the magic on the chocolate frogs will be broken. Can all the chocolate frogs safely reach Hanbyeol Land?

Input

The first line contains an integer $N$. $(1 \le N \le 1\,000)$

Output

If all chocolate frogs can safely cross the river, output the number of moves $M$ on the first line. This value does not need to be the minimum.

From the second line onwards, output the $M$ moves of the frogs in order, one per line. When the top frog at position $i$ moves to position $j$, output $i$ and $j$ separated by a space.

If they cannot cross the river, output -1 on the first line.

Examples

Input 1

2

Output 1

4
0 2
0 1
1 3
2 3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.