#include <bits/stdc++.h>
using namespace std;
int main() {
  int na, ma;
  cin >> na >> ma;
  char s[na][ma];
  for (int i = 0; i < na; i++)
    for (int j = 0; j < ma; j++) cin >> s[i][j];
  int x = 0, y = 0;
  int nb, mb;
  cin >> nb >> mb;
  char s1[nb][mb];
  int a, b;
  int max = -1;
  for (int i = 0; i < nb; i++)
    for (int j = 0; j < mb; j++) cin >> s1[i][j];
  for (x = -51; x <= 51; x++) {
    for (y = -51; y <= 51; y++) {
      int sum = 0;
      for (int k = 0; k < na; k++) {
        if (k < na && k + x < nb && k + x >= 0)
          for (int l = 0; l < ma; l++) {
            if (l < ma && l + y < mb && l + y >= 0)
              sum += (s[k][l] - '0') * (s1[k + x][l + y] - '0');
          }
      }
      if (sum > max) {
        max = sum;
        a = x;
        b = y;
      }
    }
  }
  cout << a << " " << b;
}
