#include <bits/stdc++.h>
using namespace std;
int na, ma;
int nb, mb;
char mat1[110][110];
char mat2[110][110];
int main() {
  int i, j, k, l;
  scanf("%d%d", &na, &ma);
  for (i = 0; i < na; i++) scanf("%s", mat1[i]);
  scanf("%d%d", &nb, &mb);
  for (i = 0; i < nb; i++) scanf("%s", mat2[i]);
  int ret = 0;
  int x, y;
  for (i = -max(na, nb); i <= max(na, nb); i++) {
    for (j = -max(ma, mb); j <= max(ma, mb); j++) {
      int sum = 0;
      for (k = 0; k < na; k++) {
        for (l = 0; l < ma; l++) {
          if ((i + k) < 0 || (i + k) >= nb || (j + l) < 0 || (j + l) >= mb)
            continue;
          sum += (mat1[k][l] - '0') * (mat2[k + i][l + j] - '0');
        }
      }
      if (sum > ret) {
        x = i;
        y = j;
        ret = sum;
      }
    }
  }
  printf("%d %d\n", x, y);
  return 0;
}
