#include <bits/stdc++.h>
using namespace std;
int A[60][60], B[60][60];
int N, M;
int N1, M1;
int shift(int x, int y) {
  bool flag = false;
  int ret = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      if (i + x >= N1 || j + y >= M1 || i + x < 0 || j + y < 0) continue;
      flag = true;
      ret += (A[i][j] * B[i + x][j + y]);
    }
  if (!flag) return 0;
  return ret;
}
int main() {
  int a, b, c, d;
  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      char c;
      scanf(" %c", &c);
      A[i][j] = (c - '0');
    }
  scanf("%d %d", &N1, &M1);
  for (int i = 0; i < N1; i++)
    for (int j = 0; j < M1; j++) {
      char c;
      scanf(" %c", &c);
      B[i][j] = (c - '0');
    }
  int cx = 0, cy = 0;
  int maxv = 0;
  for (int i = -51; i < 51; i++)
    for (int j = -51; j < 51; j++) {
      int ret = shift(i, j);
      if (ret > maxv) {
        maxv = ret;
        cx = i, cy = j;
      }
    }
  printf("%d %d\n", cx, cy);
  return 0;
}
