#000121

z-photo

Little Z has taken two pictures of the sky. since it was dark, the image was really noisy.


However, Little Z hands are a little bit shaky so his second image was a little bit shifted relative to the first one. It is shifted by some number of columns and some number of rows.


Your job is to find out how much is the second image shifted in both x and y direction (columns and rows). The image will always be shifted by non-negative amount of rows and columns, and will have at least one pixel overlap with the original image.


You can assume that the elements (pixels) of the image are mostly random (because of the noise). The image below is just an example of the images little Z would take if he was taking images of Lena (and not the sky)


Image: lena

InputFrom the first line read a number N, representing the size of the image (Image is N by N pixels, and 2 <= N <= 200). The next N lines will contain the first image (N rows of the first image) - each line will contain N integer values from the range [0 255]. Finally the next N lines will contain the second image, again, each line will contain N values representing the values at each pixel

OutputTo the standard output write two integers a and b that represent how much is the second image shifted relative to the first image. a is the shift in columns, and b is the shift in rows

Important: the shift will always be non-negative: 0 or more rows and 0 or more columns.

Important: if the second image can be shifted in different ways so that it still represents the same image, then output the sift with the smallest shift in columns, and if there are more of those then output the smallest shift in rows


Input:
4
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
3 4 5 0
4 5 6 7
5 6 7 8
0 7 8 9

Output:
1 1

Input:
4
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
2 3 4 5
3 4 5 6
4 5 6 7
5 6 7 8

Output:
0 1

Explanation: the second image can be shifted by (1, 0) or (0, 1) and still represent the same object, we output (0, 1) since that is the sift with smaller column shift
Input:
4
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
2 3 4 1
3 4 5 6
4 5 6 7
5 6 7 8

Output:
1 0

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.