#include <bits/stdc++.h>
using namespace std;
int d[110][110];
int n, m;
int a, b;
int ot = 1000000000;
int f(int n, int m, int a, int b) {
  int ot1 = 1000000000, ot2;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      ot2 = 0;
      for (int ii = i; ii < i + a; ++ii)
        for (int jj = j; jj < j + b; ++jj) ot2 += d[ii][jj];
      ot1 = min(ot1, ot2);
    }
  return ot1;
}
int main() {
  for (int i = 0; i < 105; ++i)
    for (int j = 0; j < 105; ++j) d[i][j] = 5;
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> d[i][j];
  cin >> a >> b;
  ot = min(ot, f(n, m, a, b));
  ot = min(ot, f(n, m, b, a));
  cout << ot;
  return 0;
}
