#include <bits/stdc++.h>
using namespace std;
int main() {
  string ar1[51], ar[51];
  int n, m, n1, m1, k = 0, x, y, mx = -99999;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) cin >> ar[i];
  scanf("%d%d", &n1, &m1);
  for (int i = 0; i < n1; i++) cin >> ar1[i];
  for (int i = -50; i <= 50; i++) {
    for (int j = -50; j <= 50; j++) {
      int sum = 0;
      for (int i1 = 0; i1 < n; i1++)
        for (int j1 = 0; j1 < m; j1++)
          if (j1 + j >= 0 && j1 + j < m1 && i1 + i >= 0 && i1 + i < n1)
            sum += (ar[i1][j1] - '0') * (ar1[i1 + i][j1 + j] - '0');
      if (sum > mx) {
        mx = sum;
        x = i;
        y = j;
      }
    }
  }
  printf("%d %d\n", x, y);
  return 0;
}
