spoj#GLASS. The Glazier
The Glazier
Jozo the glazier has made N square pieces of glass. The dimensions (sides) of these squares are equal to 1, 2, 3, ..., N - therefore, the areas of these squares equal to 12, 22, 32, ..., N2.
Four customers have arrived. Each of them buys exactly 3 pieces of of glass (Jozo will therefore sell exactly 12 pieces of glass). Each customer has stated that the sum of the dimensions of the squares he gets must be equal to N (for example he could get the pieces with dimensions 1, 2 and N-3).
Furthermore, since all customers pay the same price, Jozo wants to be fair and ensure that the sum of areas of the 3 squares must be equal for each customer (but this sum is not defined in advance). Help Jozo to choose which pieces to sell.
Input
A natural number N (12 ≤ N ≤ 1500).
Output
Print -1 if there is no solution. Otherwise, print four lines: in each of these four lines there must be three numbers from the set {1, 2, ..., N} and their sum must be equal to N. Also, the sum of squares of these three numbers must be constant for each row. All 12 numbers must be distinct.
Example
Input:
84</p>Output:
18 29 3717 33 34 18 29 37 19 27 38 22 23 3919 27 3822 23 3