#include <bits/stdc++.h>
using namespace std;
const int maxn = 60;
int a[maxn][maxn], b[maxn][maxn];
int na, ma, nb, mb;
int main() {
  int x, y, i, j, k, sum;
  cin >> na >> ma;
  for (i = 1; i <= na; ++i)
    for (j = 1; j <= ma; ++j) {
      char ch;
      cin >> ch;
      a[i][j] = ch - '0';
    }
  cin >> nb >> mb;
  for (i = 1; i <= nb; ++i)
    for (j = 1; j <= mb; ++j) {
      char ch;
      cin >> ch;
      b[i][j] = ch - '0';
    }
  int maxAns = -1, maxX = 149, maxY = -149, ans;
  for (x = 50; x >= -50; --x) {
    for (y = 50; y >= -50; --y) {
      ans = 0;
      int i1, i2, j1, j2;
      i1 = max(1 - x, 1);
      i2 = min(nb - x, na);
      j1 = max(1 - y, 1);
      j2 = min(mb - y, ma);
      for (i = i1; i <= i2; ++i) {
        for (j = j1; j <= j2; ++j) {
          ans += a[i][j] * b[i + x][j + y];
        }
      }
      if (maxAns < ans) {
        maxAns = ans;
        maxX = x;
        maxY = y;
      }
    }
  }
  if (maxX == 149 && maxY == -149) {
    cout << -1;
  } else
    cout << maxX << " " << maxY << endl;
  return 0;
}
