Time limit: 1s
Memory limit: 64MB
Input:
Output:
Task
Write a C/C++ program that reads a natural number and a sequence of natural numbers in range . It constructs in memory a two-dimensional array with rows and columns, indexed starting from , such that by traversing any column with an odd number, from top to bottom, or any column with an even number, from bottom to top, the given sequence is obtained, as shown in the example.
The program should display the resulting array on the screen, with each row of the array on a new line, and the elements of the same row separated by a space.
Example: If , and the given sequence is , the resulting array is as follows.
7 3 7 3
2 5 2 5
5 2 5 2
3 7 3 7
Input data
The first line contains two integers, and .
Output data
The required two-dimensional array from the statement will be printed.
Constraints and clarifications
- ;
- The values are in the range .
Example
stdin
4
7 2 5 3
stdout
7 3 7 3
2 5 2 5
5 2 5 2
3 7 3 7