#include <bits/stdc++.h>
using namespace std;
void read() {}
int main() {
  read();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    int n, m;
    cin >> n >> m;
    string s;
    int a[n][m];
    for (int i = 0; i < n; i++) {
      cin >> s;
      for (int j = 0; j < m; j++) {
        if (s[j] == '1')
          a[i][j] = 1;
        else
          a[i][j] = 0;
      }
    }
    int o, p;
    cin >> o >> p;
    int b[o][p];
    for (int i = 0; i < o; i++) {
      cin >> s;
      for (int j = 0; j < p; j++)
        if (s[j] == '1')
          b[i][j] = 1;
        else
          b[i][j] = 0;
    }
    int final_ans = -1, ans = 0, a1 = 0, a2 = 0;
    for (int i = -50; i < 51; i++) {
      for (int j = -50; j < 51; j++) {
        ans = 0;
        for (int k = 0; k < n; k++) {
          if (k + i < 0 or k + i >= o) continue;
          for (int l = 0; l < m; l++) {
            if (l + j < 0 or l + j >= p) continue;
            ans += a[k][l] * b[k + i][l + j];
          }
        }
        if (ans > final_ans) {
          a1 = i;
          a2 = j;
          final_ans = ans;
        }
      }
    }
    cout << a1 << " " << a2 << endl;
  }
  return 0;
}
