#include <bits/stdc++.h>
using namespace std;
bool c(char x, char y) {
  if (x == '0' || y == '0')
    return 0;
  else
    return 1;
}
int main() {
  int na, ma, nb, mb;
  cin >> na >> ma;
  char a[na][ma];
  for (int i = 0; i < na; ++i) {
    for (int j = 0; j < ma; ++j) {
      cin >> a[i][j];
    }
  }
  cin >> nb >> mb;
  char b[nb][mb];
  for (int i = 0; i < nb; ++i) {
    for (int j = 0; j < mb; ++j) {
      cin >> b[i][j];
    }
  }
  int ans = 0, ax = 0, ay = 0;
  for (int x = -50; x <= 50; ++x) {
    for (int y = -50; y <= 50; ++y) {
      int cur = 0;
      for (int i = 0; i < na; ++i) {
        for (int j = 0; j < ma; ++j) {
          int bi = i + x, bj = j + y;
          if (bi >= 0 && bi < nb && bj >= 0 && bj < mb)
            cur += c(a[i][j], b[bi][bj]);
        }
      }
      if (cur > ans) {
        ans = cur;
        ax = x;
        ay = y;
      }
    }
  }
  cout << ax << " " << ay;
}
