#include <bits/stdc++.h>
using namespace std;
int n, m, n1, m1, ans1, ans2, ans = 0, c = 0, x, y;
char a[101][101], b[101][101];
int main() {
  scanf("%d %d\n", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%c", &a[i][j]);
    }
    scanf("\n");
  }
  scanf("%d %d\n", &n1, &m1);
  for (int i = 1; i <= n1; i++) {
    for (int j = 1; j <= m1; j++) {
      scanf("%c", &b[i][j]);
    }
    scanf("\n");
  }
  for (int x = -50; x <= 50; x++)
    for (int y = -50; y <= 50; y++) {
      c = 0;
      for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
          if (i + x >= 1 && i + x <= n1 && j + y <= m1 && j + y >= 1) {
            if (a[i][j] == '1' && b[i + x][j + y] == a[i][j]) c++;
          }
        }
      if (ans < c) ans = c, ans1 = x, ans2 = y;
    }
  cout << ans1 << " " << ans2;
  fclose(stdin);
  fclose(stdout);
  return 0;
}
