#include <bits/stdc++.h>
using namespace std;
char s[55][55], str[55][55];
int main() {
  int na, nb, ma, mb;
  scanf("%d%d", &na, &ma);
  for (int i = 0; i < na; i++) scanf("%s", s[i]);
  scanf("%d%d", &nb, &mb);
  for (int i = 0; i < nb; i++) scanf("%s", str[i]);
  int idx = -1, idy = -1;
  int maxn = -1000000;
  for (int x = -50; x <= 50; x++) {
    for (int y = -50; y <= 50; y++) {
      int sum = 0;
      for (int i = 0; i < na; i++)
        for (int j = 0; j < ma; j++)
          if (i + x >= 0 && i + x < nb && j + y >= 0 && j + y < mb)
            if (s[i][j] == '1' && str[i + x][j + y] == '1') sum++;
      if (sum > maxn) idx = x, idy = y, maxn = sum;
    }
  }
  printf("%d %d\n", idx, idy);
  return 0;
}
