You've got two rectangular tables with sizes *n*<sub class="lower-index">*a*</sub> × *m*<sub class="lower-index">*a*</sub> and *n*<sub class="lower-index">*b*</sub> × *m*<sub class="lower-index">*b*</sub> cells. The tables consist of zeroes and ones. We will consider the rows and columns of both tables indexed starting from 1. Then we will define the element of the first table, located at the intersection of the *i*-th row and the *j*-th column, as *a*<sub class="lower-index">*i*, *j*</sub>; we will define the element of the second table, located at the intersection of the *i*-th row and the *j*-th column, as *b*<sub class="lower-index">*i*, *j*</sub>. 

We will call the pair of integers (*x*, *y*) a shift of the second table relative to the first one. We'll call the overlap factor of the shift (*x*, *y*) value:

where the variables *i*, *j* take only such values, in which the expression *a*<sub class="lower-index">*i*, *j*</sub>·*b*<sub class="lower-index">*i* + *x*, *j* + *y*</sub> makes sense. More formally, inequalities 1 ≤ *i* ≤ *n*<sub class="lower-index">*a*</sub>, 1 ≤ *j* ≤ *m*<sub class="lower-index">*a*</sub>, 1 ≤ *i* + *x* ≤ *n*<sub class="lower-index">*b*</sub>, 1 ≤ *j* + *y* ≤ *m*<sub class="lower-index">*b*</sub> must hold. If there are no values of variables *i*, *j*, that satisfy the given inequalities, the value of the sum is considered equal to 0. 

Your task is to find the shift with the maximum overlap factor among all possible shifts.
The first line contains two space-separated integers *n*<sub class="lower-index">*a*</sub>, *m*<sub class="lower-index">*a*</sub> (1 ≤ *n*<sub class="lower-index">*a*</sub>, *m*<sub class="lower-index">*a*</sub> ≤ 50) — the number of rows and columns in the first table. Then *n*<sub class="lower-index">*a*</sub> lines contain *m*<sub class="lower-index">*a*</sub> characters each — the elements of the first table. Each character is either a "0", or a "1".

The next line contains two space-separated integers *n*<sub class="lower-index">*b*</sub>, *m*<sub class="lower-index">*b*</sub> (1 ≤ *n*<sub class="lower-index">*b*</sub>, *m*<sub class="lower-index">*b*</sub> ≤ 50) — the number of rows and columns in the second table. Then follow the elements of the second table in the format, similar to the first table.

It is guaranteed that the first table has at least one number "1". It is guaranteed that the second table has at least one number "1".
'''
    Khushal Sindhav
    Indian Institute Of Technology, Jodhpur
    4 June 2023
'''
import sys
input = sys.stdin.readline
# print = sys.stdout.write
def exe():
    maxi=0
    indexes=[]
    for x in range(-max(n,p),max(n,p)+1):
        for y in range(-max(m,q),max(m,q)+1):
            ans=0
            for i in range(n):
                for j in range(m):
                    if -1<(i+x)<p and -1<(j+y)<q:
                        ans+=int(l1[i][j])*int(l2[i+x][j+y])
            if ans>maxi:
                indexes=[x,y]
                maxi=ans
    return indexes
 
for _ in range(1):
    n,m=map(int,input().split())
    l1=[ input().strip('\n') for i in range(n)]
    p,q=map(int,input().split())
    l2=[ input().strip('\n') for i in range(n) ]
    print(*exe())