#include <bits/stdc++.h>
using namespace std;
vector<string> a(51);
vector<string> b(51);
int main() {
  int na, ma;
  cin >> na >> ma;
  for (int i = 0; i < na; i++) {
    cin >> a[i];
  }
  int nb, mb;
  cin >> nb >> mb;
  for (int i = 0; i < nb; i++) {
    cin >> b[i];
  }
  int maxi = -1, maxi_x, maxi_y;
  for (int x = -50; x <= 50; x++) {
    for (int y = -50; y <= 50; y++) {
      int val = 0;
      for (int i = 0; i < na; i++) {
        for (int j = 0; j < ma; j++) {
          int di = i + x;
          int dj = j + y;
          if (di < 0 || dj < 0 || di >= nb || dj >= mb) continue;
          if (a[i][j] == '1' && b[di][dj] == '1') val += 1;
        }
      }
      if (maxi < val) {
        maxi = val;
        maxi_x = x;
        maxi_y = y;
      }
    }
  }
  cout << maxi_x << " " << maxi_y << endl;
  return 0;
}
