#include <bits/stdc++.h>
using namespace std;
int main() {
  int na, ma, nb, mb, i, j, x, y, val = 0, m = -1, p1, p2;
  cin >> na >> ma;
  string s1[na];
  for (i = 0; i < na; i++) {
    cin >> s1[i];
  }
  cin >> nb >> mb;
  string s2[nb];
  for (i = 0; i < nb; i++) {
    cin >> s2[i];
  }
  for (x = -50; x <= 50; x++) {
    for (y = -50; y <= 50; y++) {
      val = 0;
      for (i = 0; i < na; i++) {
        for (j = 0; j < ma; j++) {
          if (i + x < nb && i + x >= 0 && j + y < mb && j + y >= 0) {
            if (s1[i][j] == '1' && s2[i + x][j + y] == '1') {
              val++;
            }
          }
        }
      }
      if (val > m) {
        m = val;
        p1 = x;
        p2 = y;
      }
    }
  }
  cout << p1 << " " << p2;
}
