#include <bits/stdc++.h>
using namespace std;
string a[52], b[52];
int main() {
  int a1, a2, b1, b2;
  cin >> a1 >> a2;
  for (int i = 0; i < a1; i++) cin >> a[i];
  cin >> b1 >> b2;
  for (int i = 0; i < b1; i++) cin >> b[i];
  int ans = 0, mx = 0, xx = 0, yy = 0;
  for (int x = -50; x <= 50; x++)
    for (int y = -50; y <= 50; y++) {
      mx = 0;
      for (int i = 0; i < a1; i++)
        for (int j = 0; j < a2; j++)
          if ((x + i) >= 0 && (x + i) < b1 && (y + j) >= 0 && (y + j) < b2 &&
              a[i][j] == '1' && b[i + x][j + y] == '1')
            mx++;
      if (mx > ans) {
        xx = x;
        yy = y;
        ans = mx;
      }
    }
  cout << xx << " " << yy;
  return 0;
}
