#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  cin >> n >> m;
  int garden[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> garden[i][j];
  int minf = (-1u) / 2;
  int a, b;
  cin >> a >> b;
  for (int i = 0; i + a - 1 < n; i++)
    for (int j = 0; j + b - 1 < m; j++) {
      int aij = 0;
      for (int x = 0; x < a; x++)
        for (int y = 0; y < b; y++) {
          aij += garden[i + x][j + y];
        }
      minf = min(minf, aij);
    }
  swap(a, b);
  for (int i = 0; i + a - 1 < n; i++)
    for (int j = 0; j + b - 1 < m; j++) {
      int aij = 0;
      for (int x = 0; x < a; x++)
        for (int y = 0; y < b; y++) {
          aij += garden[i + x][j + y];
        }
      minf = min(minf, aij);
    }
  cout << minf << endl;
  return 0;
}
