#include <bits/stdc++.h>
using namespace std;
int na, ma, nb, mb;
int a[101][101], b[101][101];
int va, ans, ax, ay;
int main() {
  scanf("%d%d", &na, &ma);
  for (int i = 1; i <= na; i++) {
    getchar();
    for (int j = 1; j <= ma; j++) {
      if (getchar() == '1')
        a[i][j] = 1;
      else
        a[i][j] = 0;
    }
  }
  scanf("%d%d", &nb, &mb);
  for (int i = 1; i <= nb; i++) {
    getchar();
    for (int j = 1; j <= mb; j++) {
      if (getchar() == '1')
        b[i][j] = 1;
      else
        b[i][j] = 0;
    }
  }
  int n = max(na, nb);
  int m = max(ma, mb);
  for (int x = -n; x <= n; x++)
    for (int y = -m; y <= m; y++) {
      va = 0;
      for (int i = 1; i <= na; i++)
        for (int j = 1; j <= ma; j++) {
          if (i + x < 1 || i + x > nb || j + y < 1 || j + y > mb) continue;
          va += a[i][j] * b[i + x][j + y];
        }
      if (va > ans) {
        ans = va;
        ax = x;
        ay = y;
      }
    }
  printf("%d %d\n", ax, ay);
}
