#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T sqr(T t) {
  return t * t;
}
inline void files() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int n1, m1, n2, m2;
int a[150][150], b[150][150];
int mx, ansx, ansy;
int main() {
  files();
  cin >> n1 >> m1;
  for (int i = 1; i <= n1; i++)
    for (int j = 1; j <= m1; j++) {
      char c;
      cin >> c;
      a[i][j] = c - '0';
    }
  cin >> n2 >> m2;
  for (int i = 1; i <= n2; i++)
    for (int j = 1; j <= m2; j++) {
      char c;
      cin >> c;
      b[i][j] = c - '0';
    }
  for (int x = -50; x <= 50; x++) {
    for (int y = -50; y <= 50; y++) {
      int cur = 0;
      for (int i = 1; i <= n1; i++)
        for (int j = 1; j <= m1; j++)
          if (i + x <= n2 && j + y <= m2 && i + x >= 1 && j + y >= 1)
            cur += (a[i][j] * b[i + x][j + y]);
      if (mx < cur) {
        mx = cur;
        ansx = x;
        ansy = y;
      }
    }
  }
  cout << ansx << ' ' << ansy;
}
