#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  int na, ma;
  cin >> na >> ma;
  vector<vector<int> > a(na, vector<int>(ma));
  for (int i = 0; i < na; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < ma; ++j) {
      a[i][j] = s[j] - '0';
    }
  }
  int nb, mb;
  cin >> nb >> mb;
  vector<vector<int> > b(nb, vector<int>(mb));
  for (int i = 0; i < nb; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < mb; ++j) {
      b[i][j] = s[j] - '0';
    }
  }
  int ans = 0, xxx, yyy;
  for (int x = -50; x <= 50; ++x) {
    for (int y = -50; y <= 50; ++y) {
      int sum = 0;
      for (int i = 0; i < na; ++i) {
        for (int j = 0; j < ma; ++j) {
          int ni = i + x;
          int nj = j + y;
          if (not(0 <= ni and ni < nb and 0 <= nj and nj < mb)) continue;
          sum += a[i][j] * b[ni][nj];
        }
      }
      if (sum > ans) {
        ans = sum;
        xxx = x;
        yyy = y;
      }
    }
  }
  cout << xxx << " " << yyy << endl;
  return 0;
}
