#include <bits/stdc++.h>
using namespace std;
void autocheck() {}
void fast() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
}
const long long sz = LLONG_MAX;
long long sm(long long x, long long y) { return ((x + y) % sz); }
long long md2(long long x, long long y) { return ((x * y) % sz); }
long long md3(long long x, long long y, long long z) {
  return md2(x, md2(y, z));
}
int gcd(int n, int m) {
  if (n == 0) return m;
  return gcd(m % n, n);
}
long long fpow(long long a, long long b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 1) {
    long long temp = fpow(a, (b - 1) / 2);
    return md3(a, temp, temp);
  } else {
    long long temp = fpow(a, b / 2);
    return md2(temp, temp);
  }
}
int main() {
  autocheck();
  fast();
  int t = 1;
  while (t--) {
    int na, ma;
    cin >> na >> ma;
    vector<string> A(na);
    for (long long i = 0; i < na; i++) {
      cin >> A[i];
    }
    int nb, mb;
    cin >> nb >> mb;
    vector<string> B(nb);
    for (long long i = 0; i < nb; i++) {
      cin >> B[i];
    }
    int sum = 0, ans = 0;
    int X = 0, Y = 0;
    int alpha = max(na, nb), beta = max(ma, mb);
    for (long long x = -alpha; x < alpha + 1; x++) {
      for (long long y = -beta; y < beta + 1; y++) {
        sum = 0;
        for (long long i = 0; i < na; i++) {
          for (long long j = 0; j < ma; j++) {
            if (0 <= i + x && i + x < nb && 0 <= j + y && j + y < mb) {
              sum += (A[i][j] - '0') * (B[i + x][j + y] - '0');
            }
          }
        }
        if (sum > ans) {
          X = x;
          Y = y;
          ans = sum;
        }
      }
    }
    cout << X << " " << Y << endl;
  }
}
