Under construction

Still being built. Things may change

Fibonacci Souvenirs

Time limit1sMemory limit1024 MB

Summary
Split the Fibonacci numbers F_1 to F_N into two groups with equal sums, using as many numbers as possible, and print both groups.
Level

Medium7 of 10

Topics
Math, Greedy
Solved
No attempts yet

Problem

The Fibonacci sequence is defined as follows.

  • F_1=1F\_1=1
  • F_2=1F\_2=1
  • F_n=F_n−1+F_n−2F\_n=F\_{n-1}+F\_{n-2} (where n≥3n\ge 3)

Jeonghwi bought NN souvenirs with Fibonacci numbers written on them at a market in Luxor, Egypt. The souvenir numbered x(1≤x≤N)x(1\le x\le N) has F_xF\_x written on it.

Jeonghwi wants to give souvenirs to Serim and Seongju, who both like the Fibonacci sequence. If one person receives too many souvenirs, the person with fewer may be sad. So the souvenirs must be split so that the sum of the Fibonacci numbers each person receives is equal. Depending on NN, not all NN souvenirs can be distributed, and in that case the number of souvenirs given out must be as large as possible.

Split the souvenirs so that the number of souvenirs given out is maximized and the sums of the numbers each person receives are equal. A way to split them so that each person gets at least one souvenir always exists.

Input

The first line contains the number of souvenirs NN that Jeonghwi bought.

Output

On the first line, print the number XX of souvenirs Serim receives.

On the second line, print the numbers A_1,A_2,⋯ ,A_XA\_1,A\_2,\cdots ,A\_X of the souvenirs Serim receives, separated by spaces.

On the third line, print the number YY of souvenirs Seongju receives.

On the fourth line, print the numbers B_1,B_2,⋯ ,B_YB\_1,B\_2,\cdots ,B\_Y of the souvenirs Seongju receives, separated by spaces.

If there are several valid distributions, print any one of them.

Constraints

  • 2≤N≤2 0002\le N\le 2\,000
  • X,Y≥1X,Y\ge 1
  • 1≤A_i≤N(1≤i≤X)1\le A\_i\le N(1\le i\le X)
  • 1≤B_j≤N(1≤j≤Y)1\le B\_j\le N(1\le j\le Y)
  • A_1,A_2,⋯ ,A_X,B_1,B_2,⋯ ,B_YA\_1,A\_2,\cdots ,A\_X,B\_1,B\_2,\cdots ,B\_Y are distinct numbers.
  • All numbers in the input are integers.

Examples2

  1. Example 1

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

    Input
    4
    
    Expected output
    2
    1 3
    1
    4