#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first < b.first;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second == b.second) return b.first > a.first;
  return (a.second < b.second);
}
bool compmx(int a, int b) { return (a < b); }
long long int bin(long long int n) {
  long long int B_Number = 0;
  long long int c = 1;
  while (n != 0) {
    long long int rem = n % 2;
    B_Number += rem * c;
    c *= 10;
    n /= 2;
  }
  return B_Number;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
bool is_prime(long long int x) {
  if (x == 1) return false;
  if (x == 2 || x == 3) return true;
  for (long long int i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, m;
  cin >> n >> m;
  char a[n][m];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) cin >> a[i][j];
  }
  vector<pair<long long int, long long int>> v;
  long long int n1, m1;
  cin >> n1 >> m1;
  char b[n1][m1];
  for (long long int i = 0; i < n1; i++) {
    for (long long int j = 0; j < m1; j++) {
      cin >> b[i][j];
      if (b[i][j] == '1') v.push_back({i, j});
    }
  }
  long long int cnt = 0;
  long long int maxx = INT_MIN;
  long long int x = 0, y = 0;
  for (long long int i = -50; i <= 50; i++) {
    for (long long int j = -50; j <= 50; j++) {
      cnt = 0;
      for (long long int ii = 0; ii < n; ii++) {
        for (long long int jj = 0; jj < m; jj++) {
          if (ii + i < n1 && jj + j < m1 && ii + i >= 0 && jj + j >= 0)
            cnt += (a[ii][jj] - '0') * (b[ii + i][jj + j] - '0');
        }
      }
      if (cnt > maxx) {
        maxx = cnt;
        x = i;
        y = j;
      }
    }
  }
  cout << x << " " << y;
  return 0;
}
