#include <bits/stdc++.h>
using namespace std;
int n, m, mat[55][55], a, b, c, menor = 2506;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &mat[i][j]);
    }
  }
  scanf("%d%d", &a, &b);
  for (int i = 0; i <= n - a; i++) {
    for (int j = 0; j <= m - b; j++) {
      c = 0;
      for (int k = i; k < i + a; k++) {
        for (int l = j; l < j + b; l++) {
          c += mat[k][l];
        }
      }
      if (c < menor) menor = c;
    }
  }
  for (int i = 0; i <= n - b; i++) {
    for (int j = 0; j <= m - a; j++) {
      c = 0;
      for (int k = i; k < i + b; k++) {
        for (int l = j; l < j + a; l++) {
          c += mat[k][l];
        }
      }
      if (c < menor) menor = c;
    }
  }
  printf("%d", menor);
}
