#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int a, b, c, d, i, j, n, m, k, ans;
int cs[51][51];
inline int sum(int first, int second) {
  if (first < 0 || second < 0)
    return 0;
  else
    return cs[first][second];
}
inline int sum(int x2, int y2, int x1, int y1) {
  return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int _n((n)-1), i(0); i <= _n; i++) {
    for (int _n((m)-1), j(0); j <= _n; j++) {
      scanf("%d", &cs[i][j]);
      if (!i && !j)
        ;
      else if (!i)
        cs[i][j] += cs[i][j - 1];
      else if (!j)
        cs[i][j] += cs[i - 1][j];
      else
        cs[i][j] += cs[i - 1][j] + cs[i][j - 1] - cs[i - 1][j - 1];
    }
  }
  scanf("%d%d", &a, &b);
  ans = 1000000000;
  for (int _n((n)-1), i(0); i <= _n; i++) {
    for (int _n((m)-1), j(0); j <= _n; j++) {
      if (i - a + 1 >= 0 && j - b + 1 >= 0)
        ans = min(ans, sum(i, j, i - a + 1, j - b + 1));
      if (i - b + 1 >= 0 && j - a + 1 >= 0)
        ans = min(ans, sum(i, j, i - b + 1, j - a + 1));
    }
  }
  printf("%d\n", ans);
}
