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