#include <bits/stdc++.h>
using namespace std;
int main() {
  int na, ma, n, m;
  cin >> n >> m;
  na = n;
  ma = m;
  vector<vector<int> > ga(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    string line;
    cin >> line;
    for (int j = 0; j < m; j++) {
      ga[i][j] = line[j] - '0';
    }
  }
  cin >> n >> m;
  vector<vector<int> > gb(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    string line;
    cin >> line;
    for (int j = 0; j < m; j++) {
      gb[i][j] = line[j] - '0';
    }
  }
  int res = 0, maxx = 0, maxy = 0;
  for (int y = -max(n, na); y < max(n, na); y++) {
    for (int x = -max(m, ma); x < max(m, ma); x++) {
      int sum = 0;
      for (int i = 0; i < na; i++) {
        if (i + y >= n || i + y < 0) continue;
        for (int j = 0; j < ma; j++) {
          if (j + x >= m || j + x < 0) continue;
          sum += ga[i][j] * gb[i + y][j + x];
        }
      }
      if (sum > res) {
        res = sum;
        maxx = x;
        maxy = y;
      }
    }
  }
  cout << maxy << " " << maxx << endl;
  return 0;
}
