#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream &operator<<(ostream &out, const pair<A, B> &a) {
  return out << "(" << a.first << "," << a.second << ")";
}
template <class A>
ostream &operator<<(ostream &out, const vector<A> &a) {
  for (const A &it : a) out << it << " ";
  return out;
}
template <class A, class B>
istream &operator>>(istream &in, pair<A, B> &a) {
  return in >> a.first >> a.second;
}
template <class A>
istream &operator>>(istream &in, vector<A> &a) {
  for (A &i : a) in >> i;
  return in;
}
ifstream cinn("in.txt");
ofstream coutt("out.txt");
long long poww(const long long &a, long long b,
               const long long &m = 1000000007) {
  if (b == 0) return 1;
  long long first = poww(a, b / 2, m);
  first = first * first % m;
  if (b & 1) first = first * a % m;
  return first;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, n, r, s, c, h, k, f1, f2, t1, t2, i, j, ans, f, mn;
  long long na, nb, ma, mb;
  cin >> na >> ma;
  long long a[na][ma];
  char z;
  for (i = 0; i < na; i++) {
    for (j = 0; j < ma; j++) {
      cin >> z;
      a[i][j] = z - '0';
    }
  }
  cin >> nb >> mb;
  long long b[nb][mb];
  for (i = 0; i < nb; i++) {
    for (j = 0; j < mb; j++) {
      cin >> z;
      b[i][j] = z - '0';
    }
  }
  h = 0, f1 = 0, f2 = 0;
  for (t1 = -50; t1 < 51; t1++) {
    for (t2 = -50; t2 < 51; t2++) {
      f = 0;
      for (i = ((t1 < 0) ? -t1 : 0); i < na && i + t1 < nb; i++) {
        for (j = ((t2 < 0) ? -t2 : 0); j < ma && j + t2 < mb; j++) {
          f += a[i][j] * b[i + t1][j + t2];
        }
      }
      if (f > h) {
        h = f;
        f1 = t1;
        f2 = t2;
      }
    }
  }
  cout << f1 << " " << f2 << '\n';
}
