Under construction

Still being built. Things may change

Gifts

Interview

Time limit5sMemory limit1024 MB

Summary
Split candy packages numbered 1 to N into the largest number of children who each receive the same total candy count.
Level

Medium4 of 10

Topics
Math, Greedy, Implementation
Solved
No attempts yet

Problem

Bajtosia and Bajtek are preparing gifts for the students at their school for St. Nicholas Day. They agreed that the best gift is a lot of candy (not necessarily good for your teeth). Bajtek bought NN packages of candy. Package ii contains ii candies, for i=1,2,…,Ni = 1, 2, \ldots, N.

Bajtosia wants to split all the candy among as many children as possible. She does not want to open the packages, and she does not want some children to receive a different number of candies than others. One child may receive several different packages.

Can you help? Write a program that finds the largest number of children among whom all the packages can be divided so that each child gets the same number of candies.

Input

The first and only line contains one natural number NN (1≤N≤2000001 \le N \le 200000), the number of packages prepared by Bajtek.

Output

The first line of the output contains one natural number RR, the largest number of children that can receive gifts. The next RR lines describe the gifts, one child per line. The description for child ii starts with a natural number RiR_i, the number of packages child ii receives, followed by a single space and then RiR_i natural numbers, the numbers of candies in the packages given to that child.

If there are several solutions, your program may output any of them.

Examples2

  1. Example 1

    Input
    3
    
    Expected output
    2
    2 1 2
    1 3
    
  2. Example 2

    Input
    4
    
    Expected output
    2
    2 1 4
    2 2 3