#include <bits/stdc++.h>
const long long INF = 1e18;
using namespace std;
vector<long long> prime;
void SOE(long long n) {
  bool isPrime[n + 1];
  memset(isPrime, true, sizeof(isPrime));
  for (long long p = 2; p <= n; p++) {
    if (isPrime[p]) {
      for (long long i = p * p; i <= n; i += p) isPrime[i] = false;
    }
  }
  for (long long i = 2; i <= n; i++) {
    if (isPrime[i]) prime.push_back(i);
  }
}
long long POWER(long long base, long long expo) {
  long long num = 1;
  long long i = expo;
  while (i) {
    num = num * base;
    i--;
  }
  return num;
}
int main() {
  long long t = 1;
  while (t--) {
    long long na, ma, nb, mb, ans = -INF;
    cin >> na >> ma;
    string a[na];
    for (long long i = 0; i < na; i++) cin >> a[i];
    cin >> nb >> mb;
    string b[nb];
    pair<long long, long long> p;
    for (long long i = 0; i < nb; i++) cin >> b[i];
    for (long long x = -60; x <= 60; x++) {
      for (long long y = -60; y <= 60; y++) {
        long long check = 0;
        for (long long i = 0; i <= na - 1; i++) {
          for (long long j = 0; j <= ma - 1; j++) {
            if (i + x >= 0 && i + x <= nb - 1 && j + y >= 0 && j + y <= mb - 1)
              check += ((int)a[i][j] - '0') * ((int)b[i + x][j + y] - '0');
          }
        }
        if (check > ans) {
          ans = check;
          p.first = x;
          p.second = y;
        }
      }
    }
    cout << p.first << " " << p.second;
  }
  return 0;
}
