#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) { return (a > b); }
int main() {
  int na, nb, ma, mb, maks = 0, x = 0, y = 0, cek;
  char a[55][55], b[55][55];
  scanf("%d %d", &na, &ma);
  for (int i = 0; i <= na - 1; i++) scanf("%s", &a[i]);
  scanf("%d %d", &nb, &mb);
  for (int i = 0; i <= nb - 1; i++) scanf("%s", &b[i]);
  for (int i = -50; i <= 50; i++)
    for (int j = -50; j <= 50; j++) {
      cek = 0;
      for (int k = 0; k <= na - 1; k++)
        for (int l = 0; l <= ma - 1; l++)
          if (a[k][l] == '1' && k + i >= 0 && k + i < nb && l + j >= 0 &&
              l + j < mb && b[k + i][l + j] == '1')
            cek++;
      if (cek > maks) maks = cek, x = i, y = j;
    }
  printf("%d %d", x, y);
  return 0;
}
