#include <bits/stdc++.h>
using namespace std;
int main() {
  int na, ma, nb, mb, x, y;
  int a[52][52], b[52][52];
  string s;
  cin >> na >> ma;
  for (int i = 1; i <= na; i++) {
    cin >> s;
    for (int j = 1; j <= ma; ++j) {
      if (s[j - 1] == '0') {
        a[i][j] = 0;
      } else if (s[j - 1] == '1') {
        a[i][j] = 1;
      }
    }
  }
  cin >> nb >> mb;
  for (int i = 1; i <= nb; i++) {
    cin >> s;
    for (int j = 1; j <= mb; ++j) {
      if (s[j - 1] == '0') {
        b[i][j] = 0;
      } else if (s[j - 1] == '1') {
        b[i][j] = 1;
      }
    }
  }
  int sum = 0, tsum;
  x = -nb - na - 1;
  y = -mb - ma - 1;
  int tx, ty;
  for (tx = -nb - na - 1; tx <= nb; tx++) {
    for (ty = -mb - ma - 1; ty <= mb; ty++) {
      tsum = 0;
      for (int i = 1; i <= na; i++) {
        for (int j = 1; j <= ma; j++) {
          if ((i + tx <= nb) && (i + tx > 0) && (j + ty <= mb) &&
              (j + ty > 0)) {
            tsum += (a[i][j] * b[i + tx][j + ty]);
          }
        }
      }
      if (tsum > sum) {
        sum = tsum;
        x = tx;
        y = ty;
      }
    }
  }
  cout << x << " " << y;
  return 0;
}
