#include <bits/stdc++.h>
using namespace std;
char a[55][55];
char b[55][55];
int main() {
  int na, ma, nb, mb;
  scanf(" %d %d ", &na, &ma);
  for (int i = 0; i < na; i++) scanf(" %s ", &a[i]);
  scanf(" %d %d ", &nb, &mb);
  for (int i = 0; i < nb; i++) scanf(" %s ", &b[i]);
  int m = -1000111222;
  int x, y;
  for (int xx = -50; xx <= 50; xx++) {
    for (int yy = -50; yy <= 50; yy++) {
      int sum = 0;
      bool check = false;
      for (int i = 0; i < na; i++)
        for (int j = 0; j < ma; j++) {
          if (0 <= (i + xx) && (i + xx) < nb && 0 <= (j + yy) &&
              (j + yy) < mb) {
            sum += (a[i][j] - '0') * (b[i + xx][j + yy] - '0');
            check = true;
          }
        }
      if (sum > m && check) {
        m = sum;
        x = xx;
        y = yy;
      }
    }
  }
  printf("%d %d\n", x, y);
  return 0;
}
