#include <bits/stdc++.h>
int main() {
  int n, m;
  int a[100][100];
  int i, j, a1, b1, l, k;
  int flag = 0;
  int minsum = 2500;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
  scanf("%d %d", &a1, &b1);
  for (i = 0; i <= n - a1; i++) {
    for (j = 0; j <= m - b1; j++) {
      flag = 0;
      for (l = i; l < i + a1; l++) {
        for (k = j; k < j + b1; k++) {
          flag = flag + a[l][k];
        }
      }
      if (flag < minsum) {
        minsum = flag;
      }
    }
  }
  for (i = 0; i <= n - b1; i++) {
    for (j = 0; j <= m - a1; j++) {
      flag = 0;
      for (l = i; l < i + b1; l++) {
        for (k = j; k < j + a1; k++) {
          flag = flag + a[l][k];
        }
      }
      if (flag < minsum) {
        minsum = flag;
      }
    }
  }
  printf("%d\n", minsum);
  return 0;
}
