408433: GYM103118 C Cat Virus

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Cat Virustime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

In the cat country, any cat family can be regarded as a rooted tree. As we all know, a kind of zombie virus hides in all the cats' bodies. Therefore, a cat family may consist of cats and zombies. When a cat is born, it may become a zombie. If a cat becomes a zombie, all of its offspring will also become zombies.

Now given an integer $$$K$$$, you should construct a cat family with exactly $$$K$$$ ways to mark the identities (cat or zombie) of members of this family. Two ways are considered different if and only if there is at least one member that is marked as a cat in one way and marked as a zombie in the other way.

Formally, the vertices in a rooted tree will be marked black or white, and if a vertex is marked black, all the vertices in its subtree should also be marked black. Given a rooted tree, it's easy to calculate the number of possible valid ways to mark the vertices in the tree. Your task is to construct a rooted tree with exactly $$$K$$$ ways to mark your tree's vertices. Two ways are considered different if and only if there is at least one vertex such that in one way is marked black and marked white in the other way.

Input

The only line contains an integer $$$K$$$ $$$(2 \le K \le 2 \cdot 10^{18})$$$ – the number of valid ways to mark the vertices in the tree.

Output

Let's denote the number of vertices of the tree you construct as $$$n$$$, and label the vertices from $$$1$$$ to $$$n$$$ where vertex $$$1$$$ is the root.

The output should contain $$$n$$$ lines. In the first line, print one integer $$$n$$$ $$$(1 \le n \le 10^5)$$$. In the each of the next $$$n-1$$$ lines, print two integers $$$u,v$$$ $$$(1 \le u, v \le n, u \neq v)$$$ describing an edge in your rooted tree.

It is guaranteed that at least one solution exists. If there are several possible valid solutions, you can print any of them.

ExamplesInput
2
Output
1
Input
3
Output
2
1 2
Input
5
Output
3
1 2
1 3
Input
6
Output
4
1 2
2 3
2 4

加入题单

算法标签: