#include <bits/stdc++.h>
using namespace std;
int n, m, a[50][50];
int r, c, b[50][50];
inline int get(int i, int j) {
  if (i < 0 || j < 0 || i >= 50 || j >= 50) return 0;
  return b[i][j];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%1d", &a[i][j]);
  scanf("%d%d", &r, &c);
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) scanf("%1d", &b[i][j]);
  int p = max(n, r), q = max(m, c), ans = -1, ax = 0, ay = 0;
  for (int x = -p; x < p; x++)
    for (int y = -q; y < q; y++) {
      int cnt = 0;
      for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) cnt += a[i][j] * get(i + x, j + y);
      if (cnt > ans) ans = cnt, ax = x, ay = y;
    }
  printf("%d %d\n", ax, ay);
}
