#include <bits/stdc++.h>
using namespace std;
const long long MX = 100;
long long A[MX][MX];
long long acum[MX][MX];
long long n, m;
long long getAns(long long a, long long b) {
  long long ans = n * m;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (i + a - 1 < n && j + b - 1 < m) {
        long long cur = 0;
        for (long long l = i; l <= i + a - 1; l++) {
          cur += acum[l][j + b] - acum[l][j];
        }
        ans = min(ans, cur);
      }
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      acum[i][j + 1] = acum[i][j] + A[i][j];
    }
  }
  long long a, b;
  cin >> a >> b;
  long long ans = min(getAns(a, b), getAns(b, a));
  cout << ans << "\n";
  return 0;
}
