#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9;
const long long LINF = (long long)1E18;
const long double PI = acos(-1.0);
const long double EPS = 1E-12;
template <typename T>
T gcd(T a, T b) {
  return (b == 0) ? abs(a) : gcd(b, a % b);
}
template <typename T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
inline T mod(T a, T b) {
  a %= b;
  if (a < 0) a += b;
  return a;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
inline T gmax(T a, T b) {
  return (a > b ? a : b);
}
template <typename T>
inline T gmin(T a, T b) {
  return (a < b ? a : b);
}
template <typename T>
inline string toString(T x) {
  ostringstream oss;
  oss << x;
  return oss.str();
}
inline long long toInt(const string& st) {
  istringstream iss(st);
  long long x;
  iss >> x;
  return x;
}
inline long double toDouble(const string& st) {
  istringstream iss(st);
  long double x;
  iss >> x;
  return x;
}
inline string toLower(string st) {
  for (int i = 0; i < (((int)(st).size())); i++) st[i] = tolower(st[i]);
  return st;
}
inline string toUpper(string st) {
  for (int i = 0; i < (((int)(st).size())); i++) st[i] = toupper(st[i]);
  return st;
}
inline long long mul(long long b, long long e, long long n) {
  long long ret;
  while (e) {
    if (e & 1) ret = (ret + b) % n;
    e >>= 1;
    b = (b + b) % n;
  }
  return ret;
}
inline long long pow(long long b, long long e, long long n) {
  long long ret = 1;
  while (e) {
    if (e & 1) ret = mul(ret, b, n);
    e >>= 1;
    b = mul(b, b, n);
  }
  return ret;
}
int na, ma, nb, mb;
char a[500][500], b[500][500];
int main() {
  memset((a), ('0'), sizeof(a));
  memset((b), ('0'), sizeof(b));
  cin >> na >> ma;
  for (int i = (1); i <= (na); i++)
    for (int j = (1); j <= (ma); j++) cin >> a[i][j];
  cin >> nb >> mb;
  for (int i = (1); i <= (nb); i++)
    for (int j = (1); j <= (mb); j++) cin >> b[i][j];
  long long res = 0, cur;
  long long resx, resy;
  for (int x = (-50); x <= (50); x++)
    for (int y = (-50); y <= (50); y++) {
      cur = 0;
      for (int i = (1); i <= (na); i++)
        for (int j = (1); j <= (ma); j++)
          if (i + x > 0 && i + x <= nb && j + y > 0 && j + y <= mb)
            cur += (a[i][j] - '0') * (b[i + x][j + y] - '0');
      if (cur > res) {
        res = cur;
        resx = x;
        resy = y;
      }
    }
  if (res == 0) {
    cout << "-1 -1" << endl;
    return 0;
  }
  cout << resx << " " << resy << endl;
  return 0;
}
