#include <bits/stdc++.h>
using namespace std;
char a[55][55], b[55][55];
int main() {
  int ra, ca;
  cin >> ra >> ca;
  for (int i = 0; i < ra; ++i) {
    for (int j = 0; j < ca; ++j) {
      cin >> a[i][j];
    }
  }
  int rb, cb;
  cin >> rb >> cb;
  for (int i = 0; i < rb; ++i) {
    for (int j = 0; j < cb; ++j) {
      cin >> b[i][j];
    }
  }
  int ansx = -105, ansy = -105;
  int best = 0;
  for (int x = -50; x <= 50; x++) {
    for (int y = -50; y <= 50; ++y) {
      int sum = 0;
      for (int i = 0; i < ra; ++i) {
        for (int j = 0; j < ca; ++j) {
          int xb = i + x;
          int yb = j + y;
          if (xb >= 0 && yb >= 0 && xb < rb && yb < cb) {
            sum += (a[i][j] - '0') * (b[xb][yb] - '0');
          }
        }
      }
      if (sum > best) {
        best = sum;
        ansx = x, ansy = y;
      }
    }
  }
  cout << ansx << " " << ansy << endl;
}
