#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 5;
const long long int INF = 1e18;
const long long int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;
long long int a[52][52], b[52][52];
int main() {
  long long int n1, m1, n2, m2;
  cin >> n1 >> m1;
  for (long long int i = 0; i < n1; i++) {
    string second;
    cin >> second;
    for (long long int j = 0; j < second.length(); j++) {
      if (second[j] == '0') {
        a[i][j] = 0;
      } else {
        a[i][j] = 1;
      }
    }
  }
  cin >> n2 >> m2;
  for (long long int i = 0; i < n2; i++) {
    string second;
    cin >> second;
    for (long long int j = 0; j < second.length(); j++) {
      if (second[j] == '0') {
        b[i][j] = 0;
      } else {
        b[i][j] = 1;
      }
    }
  }
  long long int maxi = 0, p = 0, q = 0;
  for (long long int x = -52; x <= 52; x++) {
    for (long long int y = -52; y <= 52; y++) {
      long long int sum = 0;
      for (long long int i = 0; i < n1; i++) {
        for (long long int j = 0; j < m1; j++) {
          if (i + x < 0 || j + y < 0 || i + x >= n2 || j + y >= m2) {
            continue;
          }
          sum += a[i][j] * b[i + x][j + y];
        }
      }
      if (maxi < sum) {
        maxi = sum;
        p = x;
        q = y;
      }
    }
  }
  cout << p << " " << q << endl;
}
