#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n1, m1, n2, m2;
  cin >> n1 >> m1;
  int a[n1 + 1][m1 + 1];
  for (int i = 1; i <= n1; i++) {
    string x;
    cin >> x;
    for (int j = 0; j < m1; j++) a[i][j + 1] = x[j] - '0';
  }
  cin >> n2 >> m2;
  int b[n2 + 1][m2 + 1];
  for (int i = 1; i <= n2; i++) {
    string x;
    cin >> x;
    for (int j = 0; j < m2; j++) b[i][j + 1] = x[j] - '0';
  }
  int max = 0;
  pair<int, int> p;
  for (int x = -50; x <= 50; x++) {
    for (int y = -50; y <= 50; y++) {
      int sum = 0;
      for (int i = 1; i <= n1; i++) {
        for (int j = 1; j <= m1; j++) {
          if (i + x >= 1 and i + x <= n2 and j + y >= 1 and j + y <= m2)
            sum += a[i][j] * b[i + x][j + y];
        }
      }
      if (sum > max) {
        max = sum;
        p = make_pair(x, y);
      }
    }
  }
  cout << p.first << " " << p.second << "\n";
  return 0;
}
