#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int na, ma, nb, mb;
  char table1[51][51], table2[51][51];
  int maxsum = 0;
  int maxx = 0, maxy = 0;
  cin >> na >> ma;
  for (int i = 1; i <= na; ++i) {
    for (int j = 1; j <= ma; ++j) {
      cin >> table1[i][j];
    }
  }
  cin >> nb >> mb;
  for (int i = 1; i <= nb; ++i) {
    for (int j = 1; j <= mb; ++j) {
      cin >> table2[i][j];
    }
  }
  for (int x = -50; x <= 50; ++x) {
    for (int y = -50; y <= 50; ++y) {
      int sum = 0;
      for (int i = 1; i <= na; ++i) {
        for (int j = 1; j <= ma; ++j) {
          if (i + x >= 1 && i + x <= nb && j + y >= 1 && j + y <= mb)
            if (table1[i][j] == '1' && table2[i + x][j + y] == '1') sum++;
        }
      }
      if (sum > maxsum) {
        maxsum = sum;
        maxx = x;
        maxy = y;
      }
    }
  }
  cout << maxx << " " << maxy << endl;
  return 0;
}
