#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  ifstream from;
  const long long nmmin = 1, nmmax = 50, abmin = 1, abmax = 50;
  long long n, m, res, rt, i, i0, j, j0, k, t, ax, a, b;
  if (0) from.open("test.txt");
  cin >> n >> m;
  vector<vector<long long> > v(n);
  for (i = 0; i < n; i++) v[i].resize(m);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> v[i][j];
  cin >> a >> b;
  res = n * m;
  if ((a <= n) && (b <= m)) {
    for (i0 = 0; i0 <= n - a; i0++) {
      rt = 0;
      for (i = i0; i < i0 + a; i++)
        for (j = 0; j < b; j++) rt += v[i][j];
      res = (rt < res) ? rt : res;
      for (j0 = 1; j0 <= m - b; j0++) {
        for (i = i0; i < i0 + a; i++) rt += (v[i][j0 + b - 1] - v[i][j0 - 1]);
        res = (rt < res) ? rt : res;
      }
    }
  }
  swap(a, b);
  if ((a <= n) && (b <= m)) {
    for (i0 = 0; i0 <= n - a; i0++) {
      rt = 0;
      for (i = i0; i < i0 + a; i++)
        for (j = 0; j < b; j++) rt += v[i][j];
      res = (rt < res) ? rt : res;
      for (j0 = 1; j0 <= m - b; j0++) {
        for (i = i0; i < i0 + a; i++) rt += (v[i][j0 + b - 1] - v[i][j0 - 1]);
        res = (rt < res) ? rt : res;
      }
    }
  }
  cout << res << endl;
  return 0;
}
