#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[55][55], b[55][55];
  int na, ma, nb, mb, i, j, x, y;
  char t[100];
  scanf("%d", &na);
  scanf("%d", &ma);
  j = 0;
  for (i = 0; i < na; i++) {
    scanf("%s", t);
    j = 0;
    for (int k = 0; k < strlen(t); k++)
      if (t[k] == '1')
        a[i][j++] = 1;
      else
        a[i][j++] = 0;
  }
  scanf("%d", &nb);
  scanf("%d", &mb);
  j = 0;
  for (i = 0; i < nb; i++) {
    scanf("%s", t);
    j = 0;
    for (int k = 0; k < strlen(t); k++)
      if (t[k] == '1')
        b[i][j++] = 1;
      else
        b[i][j++] = 0;
  }
  int ans = 0, ansx = -1, ansy = -1, count = 0;
  int n = max(na, nb);
  int m = max(ma, mb);
  for (x = -n + 1; x < n; x++) {
    for (y = -m + 1; y < m; y++) {
      count = 0;
      for (i = 0; i < na; i++) {
        for (j = 0; j < ma; j++) {
          if (i + x < nb && j + y < mb && i + x >= 0 && j + y >= 0)
            if (a[i][j] == b[i + x][j + y] && a[i][j] == 1) count++;
        }
      }
      if (ans < count) {
        ansx = x;
        ansy = y;
        ans = count;
      }
    }
  }
  printf("%d %d", ansx, ansy);
  return 0;
}
