Mystical Matrix
Input: standard input
Output: standard output
Time
Limit: 1 second
The Mystical Matrix is a matrix with 3 rows and N
columns, with 1,2,..,3N each occupying one cell. Furthermore, all
rows have the same sum and all columns have the same sum. Help Jack construct
such a Mystical Matrix.
Input
The input contains several lines. Each line
contains a single positive integer N. You may assume N
is a multiple of 3 and it is less than 1000. The
input is terminated by a single integer 0.
Output a valid Mystical Matrix. If non-exists, output “IMPOSSIBLE”
(without quotes). A valid Mystical Matrix should take 3 lines,
with each line consisting of N integers separated by spaces. For
example, a 3 x 9 matrix should look like:
A1 A2 A3 A4 A5 A6 A7 A8 A9
B1 B2 B3 B4 B5 B6 B7 B8 B9
C1 C2 C3 C4 C5 C6 C7 C8 C9
Sample
Input
3
0
Sample Output
8 1 6
3 5 7
4 9 2
Problem setter: Yin Zhao (aka Bugz Podder)
"~~
When time turns on you, turn time around ~~