#include <bits/stdc++.h>
using namespace std;
signed sign(const long long);
int main() {
  bool a[52][52], b[52][52];
  int na, ma, nb, mb, i, j, maxx, maxy;
  cin >> na >> ma;
  for (i = 1; i <= na; i++) {
    for (j = 1; j <= ma; j++) {
      char c;
      cin >> c;
      a[i][j] = (c == '1');
    }
  }
  cin >> nb >> mb;
  for (i = 1; i <= nb; i++) {
    for (j = 1; j <= mb; j++) {
      char c;
      cin >> c;
      b[i][j] = (c == '1');
    }
  }
  unsigned long long maxk = 0, currk;
  int x, y, mini, minj, maxi, maxj;
  for (x = -na + 1; x < nb; x++) {
    for (y = -ma + 1; y < mb; y++) {
      currk = 0;
      mini = max(1, 1 - x);
      minj = max(1, 1 - y);
      maxi = min(nb - x, na);
      maxj = min(mb - y, ma);
      for (i = mini; i <= maxi; i++) {
        for (j = minj; j <= maxj; j++) {
          currk += ((unsigned long long)a[i][j]) *
                   ((unsigned long long)b[i + x][j + y]);
        }
      }
      if (currk > maxk) {
        maxk = currk;
        maxx = x;
        maxy = y;
      }
    }
  }
  cout << maxx << ' ' << maxy;
  return 0;
}
signed sign(const long long x) { return (x > 0) ? 1 : (x < 0) ? -1 : 0; }
