#include <bits/stdc++.h>
using namespace std;
int vl = 0;
int ax = 0, ay = 0;
int a[64][64];
int b[64][64];
int na, ma, nb, mb;
char s[64];
int main() {
  scanf("%d%d\n", &na, &ma);
  for (int i = 1; i <= na; i++) {
    gets(s + 1);
    for (int j = 1; j <= ma; j++) a[i][j] = (s[j] == '1');
  }
  scanf("%d%d\n", &nb, &mb);
  for (int i = 1; i <= nb; i++) {
    gets(s + 1);
    for (int j = 1; j <= mb; j++) b[i][j] = (s[j] == '1');
  }
  for (int x = -64; x < 64; x++)
    for (int y = -64; y < 64; y++) {
      int sum = 0;
      for (int i = 1; i <= na; i++)
        for (int j = 1; j <= ma; j++)
          if (i + x > 0 && j + y > 0 && i + x <= nb && j + y <= mb)
            sum += a[i][j] * b[i + x][j + y];
      if (sum > vl) {
        vl = sum;
        ax = x;
        ay = y;
      }
    }
  printf("%d %d\n", ax, ay);
  return 0;
}
