#include <bits/stdc++.h>
using namespace std;
int na, ma, nb, mb, a[50][50], b[50][50];
string s[50];
int b1(int x, int y) {
  return ((x >= 0) && (x < nb) && (y >= 0) && (y < mb)) ? b[x][y] : 0;
}
int main() {
  string temp;
  cin >> na >> ma;
  getline(cin, temp);
  for (int i = 0; i < na; i++) {
    getline(cin, s[i]);
    for (int j = 0; j < ma; j++) a[i][j] = int(s[i][j]) - int('0');
  }
  cin >> nb >> mb;
  getline(cin, temp);
  for (int i = 0; i < nb; i++) {
    getline(cin, s[i]);
    for (int j = 0; j < mb; j++) b[i][j] = int(s[i][j]) - int('0');
  }
  int t1, t2;
  int max = -100;
  for (int x = -60; x < 60; x++)
    for (int y = -60; y < 60; y++) {
      int ans = 0;
      for (int i = 0; i < na; i++)
        for (int j = 0; j < ma; j++) ans += a[i][j] * b1(i + x, j + y);
      if (ans > max) {
        max = ans;
        t1 = x;
        t2 = y;
      }
    }
  cout << t1 << " " << t2 << "\n";
  return 0;
}
