#include <bits/stdc++.h>
using namespace std;
int main() {
  int r1, r2, c1, c2;
  char c;
  scanf("%d", &r1);
  ;
  scanf("%d", &c1);
  ;
  scanf("%c", &c);
  ;
  char a[r1][c1];
  for (int i = 0; i < r1; i++) {
    for (int j = 0; j < c1; j++) scanf("%c", &a[i][j]);
    ;
    scanf("%c", &c);
    ;
  }
  scanf("%d", &r2);
  ;
  scanf("%d", &c2);
  ;
  scanf("%c", &c);
  ;
  char b[r2][c2];
  for (int i = 0; i < r2; i++) {
    for (int j = 0; j < c2; j++) scanf("%c", &b[i][j]);
    ;
    scanf("%c", &c);
    ;
  }
  int m = 0, x = 0, y = 0, br, bc, total;
  br = (r1 > r2) ? r1 : r2;
  bc = (c1 > c2) ? c1 : c2;
  for (int i = -br; i <= br; i++) {
    for (int j = -bc; j <= bc; j++) {
      total = 0;
      for (int k = 0; k < r1; k++) {
        for (int l = 0; l < c1; l++) {
          if ((k + i >= 0 && k + i < r2 && l + j >= 0 && l + j < c2 &&
               a[k][l] == '1' && b[k + i][l + j] == '1'))
            total++;
        }
      }
      if (total > m) {
        m = total;
        x = i;
        y = j;
      }
    }
  }
  cout << x << " " << y;
  return 0;
}
