books

Time limit: 0.5s Memory limit: 64MB Input: Output:

Task

Davide purchased NN books in preparation for the new academic year. He carefully placed them on a table in his study room.

After a few minutes, he noticed that the books were arranged in ascending order, with the smallest book at the bottom and the largest book at the top.

Realizing this, Davide decided that he preferred the books to be in a different order.

He wants to reverse their position, so the largest book is at the bottom and the smallest book is at the top.

Davide can perform the following operation a maximum of TT times: he can remove KK books from the top of pile AA and place them, in the same order, on top of pile BB (he may choose to utilize a new empty pile, if desired).

The cost of the operation will be 11 if the movement of books results in pile AA having less books than pile BB prior to the movement, and 00 otherwise.

Help Davide to reverse the order of the books while minimizing the total cost.

Input

The first line contains the only integer NN, the number of books.

Your program will be tested against several test cases grouped in subtasks. The
score in each subtask will be calculated as the minimum score obtained in any of
its test cases, multiplied by the value of the subtask.

The score of a test case is 00 if the answer is wrong or invalid, otherwise let CC be the total cost of the operations performed by your program. It can be proved that with the given constraints the minimal cost is at least 11, and a solution always exists with at most TT operations.
Your score will be calculated based on the following formula:

score = min(1log2(C)1log2(T)1,1)min(1 - \frac{\log_2(C) - 1}{\log_2(T) - 1}, 1).

Output

For each operation, output a line containing three integers KK, AA and BB.

Example 1

stdin

3

stdout

1 0 1
1 0 2
1 0 3
1 1 0
1 2 0
1 3 0

Example 2

stdin

4

stdout

1 0 1
1 0 1
1 0 2
1 0 2
2 2 1

Explanation

In the first sample case initially there are 33 books on pile 00.

We perform the following operations:

  • Move 11 book from pile 00 to pile 11 with cost 00.

  • Move 11 book from pile 00 to pile 22 with cost 00.

  • Move 11 book from pile 00 to pile 33 with cost 00.

  • Move 11 book from pile 11 to pile 00 with cost 00.

  • Move 11 book from pile 22 to pile 00 with cost 11.

  • Move 11 book from pile 33 to pile 00 with cost 11.

Finally, we have 33 books on pile 00 in the correct order, with a total cost of 22.

Note that for 33 books there exists a solution with cost 11, too, however according to the scoring formula, the solution with cost 22 gets a full score as well.

In the second sample case initially there are 44 books on pile 00.

We perform the following operations:

  • Move 11 book from pile 00 to pile 11 with cost 00.

  • Move 11 book from pile 00 to pile 11 with cost 00.

  • Move 11 book from pile 00 to pile 22 with cost 00.

  • Move 11 book from pile 00 to pile 22 with cost 11.

  • Move 22 books from pile 22 to pile 11 with cost 11.

Finally, we have 44 books on pile 11 in the correct order, with a total cost of 22.

Log in or sign up to be able to send submissions!