#include <bits/stdc++.h>
using namespace std;
int maxx;
char a[1000][1000], b[1000][1000];
int main() {
  int n1, m1, n2, m2, x, y;
  cin >> n1 >> m1;
  for (int i = 1; i <= n1; i++)
    for (int j = 1; j <= m1; j++) cin >> a[i][j];
  cin >> n2 >> m2;
  for (int i = 1; i <= n2; i++)
    for (int j = 1; j <= m2; j++) cin >> b[i][j];
  maxx = -1;
  for (int i1 = -50; i1 <= 50; i1++) {
    for (int j1 = -50; j1 <= 50; j1++) {
      int sum = 0;
      for (int i = 1; i <= n1; i++) {
        for (int j = 1; j <= m1; j++) {
          if ((i + i1) > 0 && (j + j1) > 0 && (i + i1) <= n2 &&
              (j + j1) <= m2) {
            sum += (a[i][j] - 48) * (b[i + i1][j + j1] - 48);
          }
        }
      }
      if (sum > maxx) {
        maxx = sum;
        x = i1;
        y = j1;
      }
    }
  }
  cout << x << " " << y << endl;
  return 0;
}
