#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int N = 1e3 + 9;
int a[N][N], b[N][N];
bool cmp(const pair<long long, long long> &a,
         const pair<long long, long long> &b) {
  if (a.second == b.second) {
    return a.first < b.first;
  }
  return a.second < b.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k, l;
  string s, ss;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      a[i][j] = s[j] - '0';
    }
  }
  cin >> k >> l;
  for (int i = 0; i < k; i++) {
    cin >> ss;
    for (int j = 0; j < l; j++) {
      b[i][j] = ss[j] - '0';
    }
  }
  long long xx = 0, yy = 0, ans = 0;
  for (int x = -50; x <= 50; x++) {
    for (int y = -50; y <= 50; y++) {
      long long sum = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (i + x >= 0 && i + x < k && j + y >= 0 && j + y < l) {
            sum += (a[i][j] * b[i + x][j + y]);
          }
        }
      }
      if (ans < sum) {
        ans = sum;
        xx = x;
        yy = y;
      }
    }
  }
  cout << xx << " " << yy << endl;
  return 0;
}
