#include <bits/stdc++.h>
using namespace std;
void solve() {
  int na, ma, nb, mb;
  cin >> na >> ma;
  char a[na + 1][ma + 1];
  for (int i = 1; i <= na; i++) {
    for (int j = 1; j <= ma; j++) {
      cin >> a[i][j];
    }
  }
  cin >> nb >> mb;
  char b[nb + 1][mb + 1];
  for (int i = 1; i <= nb; i++) {
    for (int j = 1; j <= mb; j++) {
      cin >> b[i][j];
    }
  }
  int x, y;
  int ans1 = -1, ans2 = -1;
  int sum = 0;
  int maxsum = 0;
  for (x = -50; x <= 50; x++) {
    for (y = -50; y <= 50; y++) {
      sum = 0;
      for (int i = 1; i <= na; i++) {
        for (int j = 1; j <= ma; j++) {
          if (x + i <= nb && y + j <= mb && x + i >= 1 && y + j >= 1)
            sum += (a[i][j] - '0') * (b[i + x][j + y] - '0');
        }
      }
      if (sum > maxsum) {
        maxsum = sum;
        ans1 = x;
        ans2 = y;
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
