#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != -1) {
    int i, j, k, t, x, y, s, s0, a[311][311];
    memset(a, 1, sizeof(a));
    for (i = 0; i < n; i++)
      for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
    scanf("%d%d", &x, &y);
    s = x * y;
    for (i = 0; i <= n - x || i <= n - y; i++)
      for (j = 0; j <= m - x || j <= m - y; j++) {
        if (i <= n - x && j <= m - y) {
          s0 = 0;
          for (k = i; k < i + x; k++)
            for (t = j; t < j + y; t++) s0 += a[k][t];
          if (s0 < s) s = s0;
        }
        if (i <= n - y && j <= m - x) {
          s0 = 0;
          for (k = i; k < i + y; k++)
            for (t = j; t < j + x; t++) s0 += a[k][t];
          if (s0 < s) s = s0;
        }
      }
    printf("%d\n", s);
  }
  return 0;
}
