#include <bits/stdc++.h>
using namespace std;
int main() {
  int na, ma, nb, mb;
  cin >> na >> ma;
  char ch1[na + 5][ma + 5];
  for (int i = 1; i <= na; i++) {
    for (int j = 1; j <= ma; j++) {
      cin >> ch1[i][j];
    }
  }
  cin >> nb >> mb;
  char ch2[nb + 5][mb + 5];
  for (int i = 1; i <= nb; i++) {
    for (int j = 1; j <= mb; j++) {
      cin >> ch2[i][j];
    }
  }
  int x = -1, y = -1, mx = -1;
  for (int xx = -50; xx <= 50; xx++) {
    for (int yy = -50; yy <= 50; yy++) {
      int sum = 0;
      for (int i = 1; i <= na; i++) {
        for (int j = 1; j <= ma; j++) {
          if (((i + xx) >= 1 && (i + xx) <= nb) &&
              ((j + yy) >= 1 && (j + yy) <= mb)) {
            sum += (ch1[i][j] - '0') * (ch2[i + xx][j + yy] - '0');
          }
        }
      }
      if (sum > mx) {
        mx = sum;
        x = xx;
        y = yy;
      }
    }
  }
  cout << x << " " << y << "\n";
  return 0;
}
