#include <bits/stdc++.h>
int n, m;
char ar[1010][1010], ar2[1010][1010];
int k, l;
void oku() {
  int i, j;
  scanf(" %d %d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      scanf(" %c", &ar[i][j]);
      ar[i][j] -= '0';
    }
  scanf(" %d %d", &k, &l);
  for (i = 1; i <= k; i++)
    for (j = 1; j <= l; j++) {
      scanf(" %c", &ar2[i][j]);
      ar2[i][j] -= '0';
    }
}
void islem() {
  int i, j, x, y, min = 0, bak, z = 0, bak2, s = 0;
  for (x = -100; x <= 100; x++)
    for (y = -100; y <= 100; y++) {
      s = 0;
      for (i = 1; i <= n; i++)
        for (j = 1; j <= m; j++) {
          if (i + x > 0 && y + j > 0 && i + x <= k && y + j <= l)
            s += ar[i][j] * ar2[i + x][y + j];
        }
      if (s > min) {
        min = s;
        bak = x;
        bak2 = y;
      }
    }
  printf("%d %d\n", bak, bak2);
}
int main() {
  oku();
  islem();
}
