Opening the Box

Time limit2sMemory limit512 MB

Summary
Find the minimum number of fixed simultaneous multi-button tests needed to identify the one correct button among N, and output the sets.
Level

Medium7 of 10

Topics
Combinatorics, Math, Implementation, Bit manipulation
Solved
No attempts yet

Problem

Hyeonuk spent a year helping his master train in a mysterious jungle and received a treasure box as a reward. The box has NN buttons, numbered 1 through NN. Exactly one of them opens the box and the rest are wrong buttons. If you press only one button and it is a wrong button, the box can never be opened again.

You can press several buttons at the same time. When you press several at once, the box makes a ding-dong sound if the buttons you pressed include the correct button, and a beep-beep sound otherwise. In this case, pressing only wrong buttons does not make the box impossible to open.

However, when you press several buttons at once, the answer does not come immediately: the sound is made about 10 to 20 minutes after you press them. Hyeonuk is impatient and wants to find out which button is correct as quickly as possible.

Hyeonuk also hates thinking, so he wants a method that presses a fixed set of buttons in sequence and reads the correct button directly from the results. In other words, he wants a method that finds the correct button no matter which button it is, as long as he presses the same fixed sequence of button sets.

Help Hyeonuk by writing a program that outputs the minimum number of button presses whose results must be checked to determine the correct button in every case, along with the set of buttons to press for each of those presses.

Input

The first line gives the integer NN.

Output

On the first line, print the minimum number of tests KK.

From the second line, print the button sets to press, one per line, over KK lines. The first number on each line is the number of buttons KiK_i to press at once, followed by the KiK_i button numbers to press together. KiK_i must be at least 2.

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

Constraints

  • 3≤N≤1053 \le N \le 10^5

Examples1

  1. Example 1

    Input
    3
    Expected output
    2
    2 1 3
    2 1 2