#include <bits/stdc++.h>
using namespace std;
int main() {
  int na, ma;
  cin >> na >> ma;
  int x[na][ma];
  char temp;
  for (int i = 0; i < na; i++) {
    for (int j = 0; j < ma; j++) {
      cin >> temp;
      x[i][j] = temp - 48;
    }
  }
  int nb, mb;
  cin >> nb >> mb;
  int y[nb][mb];
  for (int i = 0; i < nb; i++) {
    for (int j = 0; j < mb; j++) {
      cin >> temp;
      y[i][j] = temp - 48;
    }
  }
  int sum = 0;
  int max = -1, t, h;
  for (int z = -50; z <= 50; z++) {
    for (int k = -50; k <= 50; k++) {
      sum = 0;
      for (int i = 0; i < na; i++) {
        for (int j = 0; j < ma; j++) {
          if (i + z >= 0 && i + z < nb && j + k >= 0 && j + k < mb) {
            sum += (y[i + z][j + k] * x[i][j]);
          }
        }
      }
      if (sum > max) {
        t = z;
        h = k;
        max = sum;
      }
    }
  }
  cout << t << " " << h << endl;
}
