#include <bits/stdc++.h>
using namespace std;
int s[55][55];
int main() {
  int R, C, a, b, x, res = INT_MAX;
  scanf("%d", &R);
  scanf("%d", &C);
  for (int r = (1); r <= (R); ++r)
    for (int c = (1); c <= (C); ++c) {
      scanf("%d", &x);
      s[r][c] = s[r - 1][c] + s[r][c - 1] - s[r - 1][c - 1] + x;
    }
  scanf("%d", &a);
  scanf("%d", &b);
  for (int r = (1); r <= (R); ++r)
    for (int c = (1); c <= (C); ++c) {
      if (r >= a && c >= b)
        res = (res > (s[r][c] - s[r - a][c] - s[r][c - b] + s[r - a][c - b]))
                  ? (s[r][c] - s[r - a][c] - s[r][c - b] + s[r - a][c - b])
                  : res;
      if (r >= b && c >= a)
        res = (res > (s[r][c] - s[r - b][c] - s[r][c - a] + s[r - b][c - a]))
                  ? (s[r][c] - s[r - b][c] - s[r][c - a] + s[r - b][c - a])
                  : res;
    }
  printf("%d\n", res);
  return 0;
}
