#include <bits/stdc++.h>
using namespace std;
const int MAXN = 55;
int n1, m1, n2, m2;
int a[MAXN][MAXN], b[MAXN][MAXN];
bool czyDobra(int i, int j, int x, int y) {
  return ((i + x >= 1) && (j + y >= 1) && (i + x <= n2) && (j + y <= m2));
}
int daj(int x, int y) {
  int res = 0;
  for (int i = 1; i <= (n1); ++i) {
    for (int j = 1; j <= (m1); ++j) {
      if (czyDobra(i, j, x, y)) {
        res += a[i][j] * b[i + x][j + y];
      }
    }
  }
  return res;
}
void readData() {
  char c;
  scanf("%d%d", &n1, &m1);
  for (int i = 1; i <= (n1); ++i) {
    for (int j = 1; j <= (m1); ++j) {
      scanf(" %c", &c);
      a[i][j] = (int)c - (int)'0';
    }
  }
  scanf("%d%d", &n2, &m2);
  for (int i = 1; i <= (n2); ++i) {
    for (int j = 1; j <= (m2); ++j) {
      scanf(" %c", &c);
      b[i][j] = (int)c - (int)'0';
    }
  }
}
int main() {
  readData();
  int wx = 0, wy = 0, wyn = 0;
  for (int x = -55; x <= (55); ++x) {
    for (int y = -55; y <= (55); ++y) {
      if (daj(x, y) > wyn) {
        wyn = daj(x, y);
        wx = x;
        wy = y;
      }
    }
  }
  printf("%d %d\n", wx, wy);
}
