GRIDFLIP - Flipping Slipping of grids

no tags 

Given two grids of characters, consists of characters from 'a' to 'z' only. we name two grids 'A' and 'B'.

Now, we need to find the lexicographically largest triplet (Assuming that one such solution does always exists.)

Given that:

f(A, i, j, k) = B, 0 <= j < k < n and 1 <= i <= n - 2 (where 'n * n' is the size of grids)

(i.e. function 'f' operated on matrix 'A' with 'i', 'j' and 'k' parameters gives matrix 'B'.

Description of function 'f':

f(M, i, j, k) : function operated on matrix 'M' does following operations in the given order.

1) Take rows from index '0' to 'i' of the given grid M and flip it, i.e.

for( each column Ci ) reverse(A[0..i][Ci])

2) Take colums from index '0' to 'j' of the grid and flip it, i.e.

for( each row Ri ) reverse(A[Ri][0..j])

3) Take colums from index 'k' to 'n-1' of the grid and flip it, i.e.

for( each row Rj ) reverse(A[Rj][k...n-1]

4) Remove columns indexed '0' to 'j' and concatenate on the right of the grid in the same order, making new grid.

Input

First line contains one integer 'n' (n*n is size of grid)

Following n lines (i.e. line numbers 2 to n+1 ) contains strings each of size 'n' for grid 'A'.

Following n lines (i.e. line numbers n+2 to 2n+1) contains strings each of size 'n' for grid 'B'.

Constraints

5 <= n <= 1000

String contains only lower case letters.

Output

Three integers (space separated) in one line representing i, j and k respectively (lexicographically largest solution).

Example

Input:
5
ooscz
hkaea
nnzth
khdlf
rejtf
fldhk
htznn
aeakh
zcsoo
ftjer

Output:
3 3 4


Added by:parth dandiwala
Date:2013-02-27
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:BYTECODE 13