Under construction

Still being built. Things may change

Splitting Integers into Arrays

Time limit2sMemory limit256 MB

Summary
Split the integers 1 to 3n into three arrays of length n so that a_i + b_i = c_i for every i, or report -1 if no split exists.
Level

Medium5 of 10

Topics
Array, Math, Implementation
Solved
No attempts yet

Problem

Split the integers from 1 to 3n3n into three arrays aa, bb, and cc, each of length nn, so that for every ii from 1 to nn, ai+bi=cia_i + b_i = c_i holds.

Input

A single integer nn (1≤n≤231 \le n \le 23).

Output

If no solution exists, print -1 on the first line. Otherwise, print three lines of nn integers each, separated by spaces: the elements of array aa on the first line, the elements of bb on the second, and the elements of cc on the third. Each integer from 1 to 3n3n must be printed exactly once.

Examples1

  1. Example 1

    Input
    1
    
    Expected output
    1
    2
    3