#include <bits/stdc++.h>
using namespace std;
int na, ma, a[100][100];
int nb, mb, b[100][100];
int maxa = 0;
char hu[100];
int main() {
  while (scanf("%d%d", &na, &ma) != EOF) {
    if (na > ma)
      maxa = na;
    else
      maxa = ma;
    for (int i = 1; i <= na; i++) {
      scanf("%s", &hu);
      for (int j = 0; hu[j] != '\0'; j++) {
        a[i][j + 1] = hu[j] - '0';
      }
    }
    scanf("%d%d", &nb, &mb);
    if (nb > maxa) maxa = nb;
    if (mb > maxa) maxa = mb;
    for (int i = 1; i <= nb; i++) {
      scanf("%s", &hu);
      for (int j = 0; hu[j] != '\0'; j++) {
        b[i][j + 1] = hu[j] - '0';
      }
    }
    int ha = 0;
    int x, y;
    for (int i = -maxa; i <= maxa; i++) {
      for (int j = -maxa; j <= maxa; j++) {
        int sum = 0;
        for (int c = 1; c <= na; c++) {
          for (int d = 1; d <= ma; d++) {
            if (c + i >= 1 && c + i <= nb && d + j >= 1 && d + j <= mb) {
              sum += a[c][d] * b[c + i][d + j];
            }
          }
        }
        if (sum >= ha) {
          ha = sum;
          x = i;
          y = j;
        }
      }
    }
    printf("%d %d\n", x, y);
  }
  return 0;
}
