#include <bits/stdc++.h>
using namespace std;
const int N = 50 + 5;
vector<string> a, b;
string s, str;
int n, m, nn, mm, ans1, ans2;
int main() {
  cin >> n >> m;
  a.push_back("sadf");
  b.push_back("sadf");
  for (int i = 1; i <= n; i++) {
    cin >> s;
    str = "f";
    str.append(s);
    a.push_back(str);
  }
  cin >> nn >> mm;
  for (int i = 1; i <= nn; i++) {
    cin >> s;
    str = "f";
    str.append(s);
    b.push_back(str);
  }
  long long mx = -9999999, sum = 0;
  for (int x = -55; x <= 55; x++) {
    for (int y = -55; y <= 55; y++) {
      sum = 0;
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
          int q = i + x, r = y + j;
          if (q >= 1 && q <= nn && r >= 1 && r <= mm) {
            sum += (a[i][j] - '0') * (b[q][r] - '0');
          }
        }
      }
      if (sum >= mx) ans1 = x, ans2 = y, mx = sum;
    }
  }
  printf("%d %d\n", ans1, ans2);
  return 0;
}
