#include <bits/stdc++.h>
using namespace std;
int ekub(int a, int b) { return b == 0 ? a : ekub(b, a % b); }
long long s[51][51];
int main() {
  long long i, j, n, m, a, b, ans = 1e9;
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      cin >> s[i][j];
      s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    }
  cin >> a >> b;
  for (i = a; i <= n; i++)
    for (j = b; j <= m; j++)
      ans = min(ans, s[i][j] - s[i - a][j] - s[i][j - b] + s[i - a][j - b]);
  for (i = b; i <= n; i++)
    for (j = a; j <= m; j++)
      ans = min(ans, s[i][j] - s[i - b][j] - s[i][j - a] + s[i - b][j - a]);
  cout << ans;
}
