#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, p, q, t = 0, c = 0, d = 0;
  char a[64 * 3][64 * 3] = {{0}}, b[64 * 3][64 * 3] = {{0}};
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> (a[i + 64] + 64);
  cin >> p >> q;
  for (int i = 0; i < p; ++i) cin >> (b[i + 64] + 64);
  for (int x = -n; x < p; ++x)
    for (int y = -m; y < q; ++y) {
      int s = 0;
      for (int u = 64; u < 64 + n; ++u)
        for (int v = 64; v < 64 + m; ++v)
          s += ('1' == a[u][v] && '1' == b[u + x][v + y]) ? 1 : 0;
      if (s > t) t = s, c = x, d = y;
    }
  cout << c << " " << d;
}
