#include <bits/stdc++.h>
using namespace std;
const int N = 100;
string a[51], b[51];
int main() {
  int ra, rb, ca, cb, x, y, i, j, k, l, maxi, t;
  cin >> ra >> ca;
  for (int i = 0; i < ra; i++) cin >> a[i];
  cin >> rb >> cb;
  for (int i = 0; i < rb; i++) cin >> b[i];
  for (maxi = 0, k = -N; k < N; k++)
    for (l = -N; l < N; l++) {
      for (t = 0, i = 0; i < ra; i++)
        for (j = 0; j < ca; j++)
          if (i + k >= 0 && i + k < rb && j + l >= 0 && j + l < cb)
            t += (a[i][j] - '0') * (b[i + k][j + l] - '0');
      if (t > maxi) {
        maxi = t;
        x = k;
        y = l;
      }
    }
  cout << x << " " << y << endl;
  return 0;
}
