#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const int INF = 2123123123;
const int EPS = 1e-9;
inline int NUM(char c) { return (int)c - 48; }
inline char CHAR(int n) { return (char)(n + 48); }
template <class T>
inline T MAX(T a, T b) {
  if (a > b) return a;
  return b;
}
template <class T>
inline T MIN(T a, T b) {
  if (a < b) return a;
  return b;
}
inline void OPEN(const string &s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
int na, ma, nb, mb, table1[55][55], table2[55][55], t, ans, x, y;
int main() {
  int i, j, k, l;
  string s;
  scanf("%d %d", &na, &ma);
  for (i = 0; i < na; i++) {
    cin >> s;
    for (j = 0; j < ma; j++) table1[i][j] = int(s[j]) - 48;
  }
  scanf("%d %d", &nb, &mb);
  for (i = 0; i < nb; i++) {
    cin >> s;
    for (j = 0; j < mb; j++) table2[i][j] = int(s[j]) - 48;
  }
  for (i = -na; i < nb; i++)
    for (j = -ma; j < mb; j++) {
      t = 0;
      for (k = 0; k < na; k++)
        for (l = 0; l < ma; l++)
          if (i + k >= 0 && j + l >= 0 && i + k < nb && j + l < mb)
            t += table1[k][l] * table2[i + k][j + l];
      if (t >= ans) {
        x = i;
        y = j;
      }
      ans = max(t, ans);
    }
  printf("%d %d\n", x, y);
}
