SP9856 GLASS - The Glazier
Description
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 1 $ ^{2} $ , 2 $ ^{2} $ , 3 $ ^{2} $ , ..., N $ ^{2} $ .
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 Format
A natural number N (12
Output Format
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.