Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/matritsa-diagonallarni-almashtirish

Swap the diagonals

Easy 1000 ms 64 MB 31%
Share

A square matrix of size $n \times n$ is given. In every row, swap the element of the main diagonal with the element of the anti-diagonal: in row $i$, $a_{i,i}$ and $a_{i,n+1-i}$ trade places. Print the resulting matrix.

A square matrix: the two diagonal elements of each row swap places along the arrows

Input

The first line contains a positive integer $n$.
Each of the next $n$ lines contains $n$ integers — the matrix.

Output

$n$ lines with $n$ integers each.

Note

$1 \le n \le 100$
$-1000 \le a_{i,j} \le 1000$

Examples

Input #1
3
1 2 3
4 5 6
7 8 9
Output #1
3 2 1
4 5 6
9 8 7
Input #2
1
-4
Output #2
-4

Sign in to submit a solution

Signing up is free and takes a minute.