#include <bits/stdc++.h>
using namespace std;
const int MAXN = 55;
int N1, M1, N2, M2;
int a[MAXN][MAXN];
int b[MAXN][MAXN];
void read() {
  char ch;
  scanf(" %d %d", &N1, &M1);
  for (int i = 1; i <= N1; i++)
    for (int j = 1; j <= M1; j++) scanf(" %c", &ch), a[i][j] = ch == '1';
  scanf(" %d %d", &N2, &M2);
  for (int i = 1; i <= N2; i++)
    for (int j = 1; j <= M2; j++) scanf(" %c", &ch), b[i][j] = ch == '1';
}
int f(int x, int y) {
  int res = 0;
  for (int i = 1; i <= N1; i++)
    for (int j = 1; j <= M1; j++)
      if (i + x > 0 && i + x <= N2 && j + y > 0 && j + y <= M2)
        res += a[i][j] * b[i + x][j + y];
  return res;
}
int main() {
  read();
  int ans = 0;
  int t1, t2;
  for (int i = -100; i <= 100; i++)
    for (int j = -100; j <= 100; j++) {
      int tmp = f(i, j);
      if (tmp > ans) {
        t1 = i, t2 = j;
        ans = tmp;
      }
    }
  printf("%d %d\n", t1, t2);
  return 0;
}
