#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int v[101][101] = {};
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> v[i][j];
      v[i][j] += v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1];
    }
  int a, b;
  cin >> a >> b;
  int mx = a * b;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (i >= a && j >= b)
        mx = min(mx, v[i][j] - v[i - a][j] - v[i][j - b] + v[i - a][j - b]);
      if (i >= b && j >= a)
        mx = min(mx, v[i][j] - v[i - b][j] - v[i][j - a] + v[i - b][j - a]);
    }
  cout << mx;
  return 0;
}
