#include <bits/stdc++.h>
using namespace std;
int a, b;
int c, d;
char arr[60][60];
char brr[60][60];
int getAns(int x, int y) {
  int sum = 0;
  for (int i = 1; i <= a; i++) {
    for (int j = 1; j <= b; j++) {
      int xx = i + x;
      int yy = j + y;
      if (xx >= 1 && xx <= c && yy >= 1 && yy <= d && arr[i][j] == '1' &&
          brr[xx][yy] == '1') {
        sum++;
      }
    }
  }
  return sum;
}
void cal() {
  int ans = -1;
  int au = 0;
  int bu = 0;
  for (int i = -50; i <= 50; i++) {
    for (int j = -50; j <= 50; j++) {
      int u = getAns(i, j);
      if (u > ans) {
        ans = u;
        au = i;
        bu = j;
      }
    }
  }
  cout << au << " " << bu << endl;
}
int main() {
  cin >> a >> b;
  for (int i = 1; i <= a; i++) {
    for (int j = 1; j <= b; j++) {
      cin >> arr[i][j];
    }
  }
  cin >> c >> d;
  for (int i = 1; i <= c; i++) {
    for (int j = 1; j <= d; j++) {
      cin >> brr[i][j];
    }
  }
  cal();
  return 0;
}
