#include <bits/stdc++.h>
using namespace std;
inline void prin(int n) { printf("%d\n", n); }
int x1[55][55], x2[55][55];
int main() {
  int n1, m1, n2, m2, X, Y, mx = -1;
  cin >> n1 >> m1;
  char ch;
  for (int i = 0; i < (int)(n1); ++i)
    for (int j = 0; j < (int)(m1); ++j) {
      cin >> ch;
      x1[i][j] = (ch == '1');
    }
  cin >> n2 >> m2;
  for (int i = 0; i < (int)(n2); ++i)
    for (int j = 0; j < (int)(m2); ++j) {
      cin >> ch;
      x2[i][j] = (ch == '1');
    }
  for (int x = -50; x < 55; x++)
    for (int y = -50; y < 55; y++) {
      int cnt = 0;
      for (int i = 0; i < (int)(n1); ++i)
        for (int j = 0; j < (int)(m1); ++j) {
          if (i + x > n2 - 1 || j + y > m2 - 1 || i + x < 0 || j + y < 0)
            continue;
          cnt += x1[i][j] * x2[i + x][j + y];
        }
      if (cnt > mx) X = x, Y = y, mx = cnt;
    }
  cout << X << " " << Y;
}
