#include <bits/stdc++.h>
using namespace std;
void fun(int b, int d) {
  int b1 = b, d1 = d;
  int x = b % d;
  while (x) {
    b = d;
    d = x;
    x = b % d;
  }
  cout << d1 / d << "/" << b1 / d;
}
long long po(long long x) {
  long long y = 1;
  while (x--) y *= 10;
  return y;
}
long long num(long long x) {
  long long v = 0;
  while (x) {
    if (x % 10 == 9)
      v++, x /= 10;
    else
      break;
  }
  return v;
}
int main() {
  int na, ma, nb, mb;
  cin >> na >> ma;
  int arra[na + 1][ma + 1];
  arra[0][0] = 0;
  arra[0][1] = 0;
  arra[1][0] = 0;
  for (int i = 1; i <= na; i++)
    for (int j = 1; j <= ma; j++) {
      char a;
      cin >> a;
      arra[i][j] = a - '0';
    }
  cin >> nb >> mb;
  int arrb[nb + 1][mb + 1];
  arrb[0][0] = 0;
  arrb[0][1] = 0;
  arrb[1][0] = 0;
  for (int i = 1; i <= nb; i++)
    for (int j = 1; j <= mb; j++) {
      char a;
      cin >> a;
      arrb[i][j] = a - '0';
    }
  vector<pair<int, pair<int, int> > > v;
  for (int x = 1 - na; x <= nb - 1; x++) {
    for (int y = 1 - ma; y <= mb - 1; y++) {
      int sum = 0;
      for (int i = 1; i <= na; i++) {
        if (i + x < 1) continue;
        if (i + x > nb) break;
        for (int j = 1; j <= ma; j++) {
          if (j + y < 1) continue;
          if (j + y > mb) break;
          sum += arra[i][j] * arrb[i + x][j + y];
        }
      }
      v.push_back(make_pair(sum, make_pair(x, y)));
    }
  }
  sort(v.begin(), v.begin() + v.size());
  cout << v.back().second.first << " " << v.back().second.second;
  return 0;
}
