#include <bits/stdc++.h>
using namespace std;
void print2(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
void print1(int ar[], int n) {
  for (int i = 0; i < n; i++) {
    cout << ar[i] << " ";
  }
  cout << endl;
}
int main() {
  int na, ma, nb, mb;
  cin >> na >> ma;
  int ar[na][ma];
  char t;
  for (int i = 0; i < na; i++) {
    for (int j = 0; j < ma; j++) {
      cin >> t;
      ar[i][j] = int(t) - 48;
    }
  }
  cin >> nb >> mb;
  int br[nb][mb];
  for (int i = 0; i < nb; i++) {
    for (int j = 0; j < mb; j++) {
      cin >> t;
      br[i][j] = int(t) - 48;
    }
  }
  int x, y, X, Y;
  int mx = 0;
  int sum = 0;
  for (int x = -51; x < 51; x++) {
    for (int y = -51; y < 51; y++) {
      sum = 0;
      for (int i = 0; i < na; i++) {
        for (int j = 0; j < ma; j++) {
          if ((i + x < nb) && (j + y < mb) && (i + x >= 0) && (j + y >= 0)) {
            sum += ar[i][j] * br[i + x][j + y];
          }
        }
      }
      if (sum > mx) {
        mx = sum;
        X = x;
        Y = y;
      }
    }
  }
  cout << X << " " << Y << endl;
  return 0;
}
