#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int na, ma, nb, mb;
  cin >> na >> ma;
  int a[na][ma];
  for (int i = 0; i < na; i++)
    for (int j = 0; j < ma; j++) {
      char ch;
      cin >> ch;
      a[i][j] = int(ch - '0');
    }
  cin >> nb >> mb;
  int b[nb][mb];
  for (int i = 0; i < nb; i++)
    for (int j = 0; j < mb; j++) {
      char ch;
      cin >> ch;
      b[i][j] = int(ch - '0');
    }
  int ans = -1, posx = 0, posy = 0;
  for (int x = -50; x < 51; x++) {
    for (int y = -50; y < 51; y++) {
      int sum = 0;
      for (int i = 0; i < na; i++) {
        for (int j = 0; j < ma; j++) {
          if ((i + x) >= 0 && (j + y) >= 0 && (i + x) < nb && (j + y) < mb)
            sum += a[i][j] * b[i + x][j + y];
        }
      }
      if (sum > ans) {
        posx = x;
        posy = y;
        ans = sum;
      }
    }
  }
  cout << posx << " " << posy << endl;
  return 0;
}
