#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 55;
char sa[MAX_N][MAX_N];
char sb[MAX_N][MAX_N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int ca, ra, cb, rb;
  cin >> ra >> ca;
  for (int i = 0; i < ra; ++i)
    for (int j = 0; j < ca; ++j) cin >> sa[i][j];
  cin >> rb >> cb;
  for (int i = 0; i < rb; ++i)
    for (int j = 0; j < cb; ++j) cin >> sb[i][j];
  int ansx, ansy;
  int ans = -1;
  for (int x = -55; x < 55; ++x)
    for (int y = -55; y < 55; ++y) {
      int res = 0;
      for (int i = 0; i < ra; ++i)
        for (int j = 0; j < ca; ++j) {
          if (i + x >= 0 && i + x < rb && j + y >= 0 && j + y < cb) {
            if (sa[i][j] == '1' && sb[i + x][j + y] == '1') ++res;
          }
        }
      if (res > ans) {
        ans = res;
        ansx = x;
        ansy = y;
      }
    }
  cout << ansx << " " << ansy << endl;
  return 0;
}
