Description
A Fancy square Image encryption algorithm works as follow:
0. Consider the image as an n x n matrix
1. Choose an integer k∈{0, 1, 2, 3}
2. Rotate the square image K * degree clockwise
3. If N is odd stop the encryption process
4. If N is even split the image to four equal sub-squares whose length is N/2 and encrypt them recursively starting FR Om Step 0
Apparently different choices of the K Serie result in different encrypted images. Given-Images A and B, your task is to find out whether it's POSSIBLE that's encrypted from A. B is possibly Encryp Ted from a if there are A choice of K serie that encrypt A into B.
Input
Input may contains multiple testcases.
The first line of the input contains a integer t (1 <= t <=) which is the number of testcases.
The first line of each testcase are an integer N, the length of the side of the images A and B.
The following n lines each contain n integers, indicating the image A.
The next following n lines each contain n integers, indicating the image B.
For 20% of the data, 1 <= n <= 15
For 100% of the data, 1 <= n <=, 0 <= Aij, Bij <= 100000000
Output
For the testcase output Yes or No according to whether it was possible that B was encrypted from A.
-
Sample Input
-
321 23 43 14 221 24 33 14 244 1 2 31 2 3 42 3 4 13 4 1 23 4 4 12 3 1 21 4 4 32 1 3 2
-
Sample Output
-
Yesnoyes
Hihocoder #1240 Image encryption