## strings : medium

Time Limit: 1 sec
Memory Limit: 256 MB
Attempts: 0
Accuracy: 0.00%
Author: Akashdeep Goel

Sheldon and Raj are playing a game with matrices. Sheldon gives a mxn matrix to Raj and asks him to calculate the Sheldonian string of the given matrix. Sheldonian string of a given matrix is defined as a string of numbers formed by printing the square of number at each position in the matrix when traaversing the matrix in spiral order.

eg given a 2x2 matrix : 4 5

10 20

The spiral order is 4, 5, 20, 10

The Sheldonian string is : 16 25 400 100

eg given a 3x3 matrix : 4 5 6

10 20 30

60 50 40

The spiral order is 4 5 6 30 40 50 60 10 20

The Sheldonian string is : 16 25 36 900 1600 2500 3600 100 400

Input :

First line contains T - the number of test cases.

Each test case consists of 2 integers m, n (the given matrix is of size mxn). Next m lines describe the m rows of the matrix. Each line consists of n space seperated integers.

Output :

Print the Sheldonian string corresponding to every test case. Leave a blank line after printing one Sheldonian string. Numbers in a string should be seperated by spaces.

Constraint :

1 < T < 600

0 < n, m < 100

0 < all integers < 1000000

Example :

Input :

2

3 3

4 5 6

10 20 30

60 50 40

2 2

4 5

10 20

Output :

16 25 36 900 1600 2500 3600 100 400

16 25 400 100

ID

SUBMITTED AT

STATUS

LANGUAGE

TIME

MEMORY USED

USER

TIME

STATUS

LANGUAGE

TIME

MEMORY USED