#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
double PI = 3.1415926535897932384626433832795;
const int N = 52;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int a[N][N], b[N][N];
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      stringstream ss;
      char c;
      cin >> c;
      ss << c;
      ss >> a[i][j];
      ss.clear();
    }
  }
  int nn, mm;
  cin >> nn >> mm;
  for (int i = 0; i < nn; i++) {
    for (int j = 0; j < mm; j++) {
      stringstream ss;
      char c;
      cin >> c;
      ss << c;
      ss >> b[i][j];
      ss.clear();
    }
  }
  int resX = 0, resY = 0, res = 0, mx = 0;
  for (int x = -N; x <= N; x++) {
    for (int y = -N; y <= N; y++) {
      res = 0;
      for (int i = 0; i < n; i++) {
        if (i + x < 0 || i + x >= nn) continue;
        for (int j = 0; j < m; j++) {
          if (j + y < 0 || j + y >= mm) continue;
          res += a[i][j] * b[i + x][j + y];
        }
      }
      if (mx < res) {
        mx = res;
        resX = x;
        resY = y;
      }
    }
  }
  cout << resX << " " << resY;
  return 0;
}
