#include <bits/stdc++.h>
char cap1[55][55], cap2[55][55];
int main() {
  int n1, m1, n2, m2, i, j, x, y, anssum, ansx, ansy;
  while (scanf("%d%d", &n1, &m1) != EOF) {
    anssum = -1;
    getchar();
    for (i = 0; i < n1; i++) gets(cap1[i]);
    scanf("%d%d", &n2, &m2);
    getchar();
    for (i = 0; i < n2; i++) gets(cap2[i]);
    for (x = -n1; x < n2; x++) {
      for (y = -m1; y < m2; y++) {
        int sum = 0;
        for (i = 1; i <= n1; i++) {
          for (j = 1; j <= m1; j++) {
            if (i + x > 0 && i + x <= n2 && j + y > 0 && j + y <= m2) {
              sum += (cap1[i - 1][j - 1] - '0') *
                     (cap2[i + x - 1][j + y - 1] - '0');
            }
          }
        }
        if (sum > anssum) {
          anssum = sum;
          ansx = x;
          ansy = y;
        }
      }
    }
    printf("%d %d\n", ansx, ansy);
  }
  return 0;
}
