#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, a, b, ans = 1e5;
  cin >> n >> m;
  vector<vector<int>> vec(n, vector<int>(m));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      cin >> vec[i][j];
    }
  cin >> a >> b;
  for (int i = 0; i < n - a + 1; ++i)
    for (int j = 0; j < m - b + 1; ++j) {
      int s = 0;
      for (int i1 = i; i1 < i + a; ++i1)
        for (int j1 = j; j1 < j + b; ++j1) {
          s += vec[i1][j1];
        }
      if (s < ans) ans = s;
    }
  for (int i = 0; i < n - b + 1; ++i)
    for (int j = 0; j < m - a + 1; ++j) {
      int s = 0;
      for (int i1 = i; i1 < i + b; ++i1)
        for (int j1 = j; j1 < j + a; ++j1) {
          s += vec[i1][j1];
        }
      if (s < ans) ans = s;
    }
  cout << ans << endl;
  return 0;
}
