#include <bits/stdc++.h>
using namespace std;
int n, m, mas[100][100], a, b, minn = 99999999;
void pro(int a, int b) {
  if (a <= n && b <= m) {
    for (int i = 0; i < n - a + 1; ++i)
      for (int j = 0; j < m - b + 1; ++j) {
        int res = 0;
        for (int k = 0; k < a; ++k)
          for (int l = 0; l < b; ++l) res += mas[k + i][l + j];
        minn = min(res, minn);
      }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> mas[i][j];
  cin >> a >> b;
  pro(a, b);
  pro(b, a);
  cout << minn;
  return 0;
}
