#include <bits/stdc++.h>
using namespace std;
int na, ma, nb, mb;
char s[55][55];
char t[55][55];
int main() {
  while (~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", t[i]);
    int ans = 0, xx = 0, yy = 0;
    int n = max(na, nb), m = max(ma, mb);
    for (int x = -n; x <= n; x++)
      for (int y = -m; y <= m; y++) {
        int tmp = 0;
        for (int i = 0; i < na; i++)
          for (int j = 0; j < ma; j++)
            if (i + x < nb && j + y < mb && i + x >= 0 && j + y >= 0)
              tmp += (s[i][j] == '1') & (t[i + x][j + y] == '1');
        if (ans < tmp) ans = tmp, xx = x, yy = y;
      }
    printf("%d %d\n", xx, yy);
  }
  return 0;
}
