#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const long long LINF = 1LL * INF * INF;
const int MAX = 100010;
const long double PI = acos(-1.);
const double EPS = 1e-6;
long long mod = 1000LL * 1000 * 1000 + 7;
int A[57][57];
int B[57][57];
int main() {
  int na, ma;
  cin >> na >> ma;
  for (int i = 0; i < na; ++i)
    for (int j = 0; j < ma; ++j) {
      char t;
      cin >> t;
      A[i][j] = t - '0';
    }
  int nb, mb;
  cin >> nb >> mb;
  for (int i = 0; i < nb; ++i)
    for (int j = 0; j < mb; ++j) {
      char t;
      cin >> t;
      B[i][j] = t - '0';
    }
  int res = 0;
  pair<int, int> ans = make_pair(0, 0);
  for (int x = -50; x < 51; ++x)
    for (int y = -50; y < 51; ++y) {
      int sum = 0;
      for (int i = 0; i < 50; ++i)
        for (int j = 0; j < 50; ++j)
          if (i < na && j < ma && i + x < nb && i + x >= 0 && j + y < mb &&
              j + y >= 0)
            sum += A[i][j] * B[i + x][j + y];
      if (sum > res) {
        res = sum;
        ans = make_pair(x, y);
      }
    }
  cout << ans.first << " " << ans.second;
  return 0;
}
