#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T b, T p, T m) {
  T ret;
  if (p == 0) return 1;
  if (p & 1) {
    ret = (bigmod(b, p / 2, m) % m);
    return ((b % m) * ret * ret) % m;
  } else {
    ret = (bigmod(b, p / 2, m) % m);
    return (ret * ret) % m;
  }
}
int dx4[] = {1, -1, 0, 0};
int dy4[] = {0, 0, 1, -1};
int dx6[] = {0, 0, 1, -1, 0, 0};
int dy6[] = {1, -1, 0, 0, 0, 0};
int dz6[] = {0, 0, 0, 0, 1, -1};
int dx8[] = {1, -1, 0, 0, -1, 1, -1, 1};
int dy8[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dkx8[] = {-1, 1, -1, 1, -2, -2, 2, 2};
int dky8[] = {2, 2, -2, -2, 1, -1, 1, -1};
int tc = 1;
const double eps = 1e-9;
const double pi = acos(-1.0);
const long long int mx = 50;
const long long int mod = 1000000007;
int na, ma, nb, mb, a[mx + 5][mx + 5], b[mx + 5][mx + 5];
int calc(int x, int y) {
  int i, j, nx, ny, ans = 0;
  for (i = 0; i < na; i++) {
    for (j = 0; j < ma; j++) {
      nx = i + x;
      ny = j + y;
      if (nx >= 0 && nx < nb && ny >= 0 && ny < mb) ans += a[i][j] * b[nx][ny];
    }
  }
  return ans;
}
int main() {
  int i, j, x, y, cur, best;
  cin >> na >> ma;
  for (i = 0; i < na; i++) {
    for (j = 0; j < ma; j++) scanf("%1d", &a[i][j]);
  }
  cin >> nb >> mb;
  for (i = 0; i < nb; i++) {
    for (j = 0; j < mb; j++) scanf("%1d", &b[i][j]);
  }
  best = 0;
  for (i = -50; i <= 50; i++) {
    for (j = -50; j <= 50; j++) {
      cur = calc(i, j);
      if (cur > best) {
        best = cur;
        x = i;
        y = j;
      }
    }
  }
  cout << x << " " << y << "\n";
  return 0;
}
