#include <bits/stdc++.h>
using namespace std;
int arr1[55][55];
int arr2[55][55];
char z;
int main() {
  int n1, m1, n2, m2;
  cin >> n1 >> m1;
  for (int i = 1; i <= n1; i++) {
    for (int j = 1; j <= m1; j++) {
      cin >> z;
      arr1[i][j] = z - '0';
    }
  }
  cin >> n2 >> m2;
  for (int i = 1; i <= n2; i++) {
    for (int j = 1; j <= m2; j++) {
      cin >> z;
      arr2[i][j] = z - '0';
    }
  }
  int a = 0, b = 0, ans = 0, t = 0;
  for (int x = -50; x <= 50; x++) {
    for (int y = -50; y <= 50; y++) {
      t = 0;
      for (int i = 1; i <= n1; i++) {
        if (i + x > n2) break;
        if (i + x < 1) continue;
        for (int j = 1; j <= m1; j++) {
          if (j + y > m2) break;
          if (j + y < 1) continue;
          t += (arr1[i][j] * arr2[i + x][j + y]);
        }
      }
      if (t > ans) {
        a = x;
        b = y;
        ans = t;
      }
    }
  }
  cout << a << " " << b;
  return 0;
}
