#include <bits/stdc++.h>
using namespace std;
int na, ma, nb, mb;
int main() {
  scanf("%d %d ", &na, &ma);
  char matrix1[na + 1][ma + 1];
  for (int i = 1; i <= na; i++)
    for (int j = 1; j <= ma; j++) scanf("%c ", &matrix1[i][j]);
  scanf("%d %d ", &nb, &mb);
  char matrix2[nb + 1][mb + 1];
  for (int i = 1; i <= nb; i++)
    for (int j = 1; j <= mb; j++) scanf("%c ", &matrix2[i][j]);
  int maxsum = 0;
  int sum = 0;
  int MAXx = 0, MAXy = 0;
  for (int x = -50; x <= 50; x++)
    for (int y = -50; y <= 50; y++) {
      sum = 0;
      for (int i = 1; i <= na; i++)
        for (int j = 1; j <= ma; j++)
          if (x + i >= 1 && x + i <= nb && y + j >= 1 && y + j <= mb)
            if (matrix1[i][j] == '1' && matrix2[i + x][j + y] == '1') sum++;
      if (maxsum < sum) {
        maxsum = sum;
        MAXx = x;
        MAXy = y;
      }
    }
  printf("%d %d\n", MAXx, MAXy);
  return 0;
}
