#C1817. Serpentine Matrix Generation

    ID: 45064 Type: Default 1000ms 256MiB

Serpentine Matrix Generation

Serpentine Matrix Generation

Given a positive integer \(n\), generate an \(n \times n\) serpentine matrix. In this matrix, the numbers in rows with even indices (0-indexed) are filled from left to right in increasing order, while the numbers in rows with odd indices are filled from right to left in increasing order. For example, when \(n = 3\), the matrix should be:

1 2 3
6 5 4
7 8 9

Your task is to read an integer from standard input and output the matrix with each row printed on a new line and numbers separated by a single space.

inputFormat

The input consists of a single integer \(n\) (\(1 \leq n \leq 1000\)) on standard input.

outputFormat

Output the generated serpentine matrix. Print each row on a new line with the numbers separated by a space.

## sample
3
1 2 3

6 5 4 7 8 9

</p>