#include <bits/stdc++.h>
using namespace std;
long long n, m, s[51][51], x, a, b, ans = 1e9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> x;
      s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + x;
    }
  }
  cin >> a >> b;
  if (a <= n && b <= m) {
    for (long long i = 0; i <= n - a; i++)
      for (long long j = 0; j <= m - b; j++) {
        ans = min(ans, s[i + a][j + b] - s[i][j + b] - s[i + a][j] + s[i][j]);
      }
  }
  if (a <= m && b <= n) {
    for (long long i = 0; i <= n - b; i++)
      for (long long j = 0; j <= m - a; j++) {
        ans = min(ans, s[i + b][j + a] - s[i][j + a] - s[i + b][j] + s[i][j]);
      }
  }
  cout << ans << '\n';
}
