#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int F[n][m];
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) scanf("%d", &F[i][j]);
  int a, b;
  scanf("%d%d", &a, &b);
  int res = 1 << 29;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) {
      if (i + a <= n && j + b <= m) {
        int cr = 0;
        for (int cx = (0); cx < (a); ++cx)
          for (int cy = (0); cy < (b); ++cy) cr += F[i + cx][j + cy];
        res = min(cr, res);
      }
      if (i + b <= n && j + a <= m) {
        int cr = 0;
        for (int cx = (0); cx < (b); ++cx)
          for (int cy = (0); cy < (a); ++cy) cr += F[i + cx][j + cy];
        res = min(cr, res);
      }
    }
  printf("%d\n", res);
  return 0;
}
