#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
long long n1, m1, n2, m2;
const long long maxn = 55;
char a[maxn][maxn], b[maxn][maxn];
long long check(long long x, long long y) {
  long long ans = 0;
  for (long long i = 0; i < max(n1, n2); i++) {
    for (long long j = 0; j < max(m1, m2); j++) {
      if (i + x >= 0 && j + y >= 0 && i + x < n2 && j + y < m2 && i < n1 &&
          j < m1) {
        long long t1 = a[i][j] - '0', t2 = b[i + x][j + y] - '0';
        ans += (t1 * t2);
      }
    }
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n1 >> m1;
  for (long long i = 0; i < n1; i++) {
    for (long long j = 0; j < m1; j++) cin >> a[i][j];
  }
  cin >> n2 >> m2;
  for (long long i = 0; i < n2; i++) {
    for (long long j = 0; j < m2; j++) cin >> b[i][j];
  }
  long long maxi = 0, ansi = 0, ansj = 0;
  for (long long x = -max(n1, n2); x <= max(n1, n2); x++) {
    for (long long y = -max(m1, m2); y <= max(m1, m2); y++) {
      long long ans = 0;
      for (long long i = 0; i < max(n1, n2); i++) {
        for (long long j = 0; j < max(m1, m2); j++) {
          if (i + x >= 0 && j + y >= 0 && i + x < n2 && j + y < m2 && i < n1 &&
              j < m1) {
            long long t1 = a[i][j] - '0', t2 = b[i + x][j + y] - '0';
            ans += (t1 * t2);
          }
        }
      }
      if (ans > maxi) {
        maxi = ans;
        ansi = x;
        ansj = y;
      }
    }
  }
  cout << ansi << " " << ansj << "\n";
  return 0;
}
