#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30);
int ans = inf, i, j, n, m, N, M, a[100][100];
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> a[i][j];
  for (j = 1; j <= m; j++) a[1][j] += a[1][j - 1];
  for (i = 1; i <= n; i++) a[i][1] += a[i - 1][1];
  for (i = 2; i <= n; i++)
    for (j = 2; j <= m; j++)
      a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
  cin >> N >> M;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      if (i - N + 1 > 0 && j - M + 1 > 0)
        ans = min(ans, a[i][j] - a[i - N][j] - a[i][j - M] + a[i - N][j - M]);
      if (i - M + 1 > 0 && j - N + 1 > 0)
        ans = min(ans, a[i][j] - a[i - M][j] - a[i][j - N] + a[i - M][j - N]);
    }
  cout << ans;
  return 0;
}
