#include <bits/stdc++.h>
using namespace std;
int n, m, w, h, a[60][60], ans;
int main() {
  ans = 1 << 30;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  scanf("%d%d", &h, &w);
  int x = 0, y = 0, sum = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum = 0;
      if (i + h <= n + 1 && j + w <= m + 1) {
        for (int x = i; x < i + h; x++)
          for (int y = j; y < j + w; y++) sum += a[x][y];
        ans = min(ans, sum);
      }
      sum = 0;
      if (i + w <= n + 1 && j + h <= m + 1) {
        for (int x = i; x < i + w; x++)
          for (int y = j; y < j + h; y++) sum += a[x][y];
        ans = min(ans, sum);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
