#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long MOD1 = 998244353;
double eps = 1e-12;
const string NAME = "";
const int MOD = 1e9 + 7;
long long binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (!a || !b) return a | b;
  unsigned long long shift = __builtin_ctz(a | b);
  a >>= __builtin_ctz(a);
  do {
    b >>= __builtin_ctz(b);
    if (a > b) swap(a, b);
    b -= a;
  } while (b);
  return a << shift;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int na, ma;
  cin >> na >> ma;
  char a[na][ma];
  for (long long i = 0; i < na; i++)
    for (long long j = 0; j < ma; j++) cin >> a[i][j];
  int nb, mb;
  cin >> nb >> mb;
  char b[nb][mb];
  for (long long i = 0; i < nb; i++)
    for (long long j = 0; j < mb; j++) cin >> b[i][j];
  int c = 0, idx = -1, idy = -1, mx = -1;
  for (int x = -50; x <= 50; x++)
    for (int y = -50; y <= 50; y++) {
      c = 0;
      for (long long i = 0; i < 50; i++)
        for (long long j = 0; j < 50; j++)
          if (i < na && j < ma && i + x >= 0 && i + x < nb && j + y >= 0 &&
              j + y < mb)
            c += ((a[i][j] - '0') * (b[i + x][j + y] - '0'));
      if (c > mx) {
        mx = c;
        idx = x;
        idy = y;
      }
    }
  cout << idx << " " << idy;
  return 0;
  return 0;
}
