#include <bits/stdc++.h>
using namespace std;
int a[55][55], b[55][55];
int main() {
  char c[100];
  int i, j, k, l, na, ma, nb, mb;
  scanf("%d %d", &na, &ma);
  for (i = (1); i <= (na); i++) {
    scanf("%s", c);
    for (j = (1); j <= (ma); j++) a[i][j] = c[j - 1] - '0';
  }
  scanf("%d %d", &nb, &mb);
  for (i = (1); i <= (nb); i++) {
    scanf("%s", c);
    for (j = (1); j <= (mb); j++) b[i][j] = c[j - 1] - '0';
  }
  int x, y;
  int ans = 0, ansx = 0, ansy = 0;
  for (x = (1 - na); x <= (nb - 1); x++)
    for (y = (1 - ma); y <= (mb - 1); y++) {
      int sum = 0;
      for (i = (1); i <= (na); i++)
        for (j = (1); j <= (ma); j++) {
          if (1 <= i + x && i + x <= nb && 1 <= j + y && j + y <= mb)
            sum += a[i][j] * b[i + x][j + y];
        }
      if (sum > ans) {
        ans = sum;
        ansx = x;
        ansy = y;
      }
    }
  printf("%d %d\n", ansx, ansy);
}
