#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
void clock_out() {
  cerr << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
}
void fileio() {
  freopen("/home/dwai/Desktop/cp/input.txt", "r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}
void ofileio() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
int IT_MAX = 1 << 20;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
void solve() {
  long long n1, m1;
  cin >> n1 >> m1;
  char a[n1][m1];
  long long i, j;
  for (i = 0; i < n1; i++)
    for (j = 0; j < m1; j++) cin >> a[i][j];
  long long n2, m2;
  cin >> n2 >> m2;
  char b[n2][m2];
  for (i = 0; i < n2; i++)
    for (j = 0; j < m2; j++) cin >> b[i][j];
  long long x = 0, y = 0, mv = 0;
  for (i = -50; i <= 50; i++) {
    for (j = -50; j <= 50; j++) {
      long long ii = 0, jj = 0;
      long long cv = 0;
      for (ii = 0; ii < n1; ii++) {
        for (jj = 0; jj < m1; jj++) {
          if (ii + i >= n2 || jj + j >= m2 || ii + i < 0 || jj + j < 0)
            continue;
          int v1 = a[ii][jj] - '0';
          int v2 = b[ii + i][jj + j] - '0';
          cv += v1 * v2;
        }
      }
      if (cv > mv) {
        mv = cv;
        x = i;
        y = j;
      }
    }
  }
  if (mv == 0) {
    cout << "-1 -1";
    return;
  }
  cout << x << " " << y;
}
int main() {
  42;
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  solve();
  return 0;
}
