#include <bits/stdc++.h>
using namespace std;
bool cus(pair<int, int> a, pair<int, int> b) {
  if (a.first < b.first) return true;
  if (a.first > b.first) return false;
  return a.second < b.second;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void solve() {
  string s;
  long long na, ma;
  cin >> na >> ma;
  vector<vector<long long> > a(na, vector<long long>(ma));
  for (long long i = 0, _n = (na); i < _n; i++) {
    cin >> s;
    for (long long j = 0, _n = (s.size()); j < _n; j++) {
      a[i][j] = s[j] - '0';
    }
  }
  long long nb, mb;
  cin >> nb >> mb;
  vector<vector<long long> > b(nb, vector<long long>(mb));
  for (long long i = 0, _n = (nb); i < _n; i++) {
    cin >> s;
    for (long long j = 0, _n = (mb); j < _n; j++) {
      b[i][j] = s[j] - '0';
    }
  }
  long long mx = -10000000000;
  long long xmax, ymax;
  long long mxa = max(mb, ma);
  long long mna = max(na, nb);
  for (long long x = (-mna + 1), _b = (mna - 1); x <= _b; x++) {
    for (long long y = (-mxa + 1), _b = (mxa - 1); y <= _b; y++) {
      long long sm = 0;
      for (long long i = 0, _n = (na); i < _n; i++) {
        for (long long j = 0, _n = (ma); j < _n; j++) {
          if (i + x < nb && j + y < mb && i + x >= 0 && j + y >= 0)
            sm += a[i][j] * b[i + x][j + y];
        }
      }
      if (sm > mx) {
        mx = sm;
        xmax = x;
        ymax = y;
      }
    }
  }
  cout << xmax << " " << ymax << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(11);
  solve();
  return 0;
}
