#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
int g[55][55];
int cnt(int x1, int x2, int y1, int y2) {
  int r = 0;
  for (int i = x1; i < x2; i++) {
    for (int j = y1; j < y2; j++) {
      r += g[i][j];
    }
  }
  return r;
}
int main(void) {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &g[i][j]);
    }
  }
  scanf("%d %d", &a, &b);
  int r = 2 * n * m;
  for (int i = 0; i <= n - a; i++) {
    for (int j = 0; j <= m - b; j++) {
      int c = cnt(i, i + a, j, j + b);
      if (c < r) {
        r = c;
      }
    }
  }
  for (int i = 0; i <= n - b; i++) {
    for (int j = 0; j <= m - a; j++) {
      int c = cnt(i, i + b, j, j + a);
      if (c < r) {
        r = c;
      }
    }
  }
  printf("%d\n", r);
  return 48 - 48;
}
