#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
int w[55][55];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> w[i][j];
    }
  }
  cin >> a >> b;
  int ans = n * m;
  for (int i = 1; i + a - 1 <= n; i++) {
    for (int j = 1; j + b - 1 <= m; j++) {
      int cnt = 0;
      for (int k = i; k <= i + a - 1; k++) {
        for (int l = j; l <= j + b - 1; l++) {
          cnt += w[k][l];
        }
      }
      ans = min(ans, cnt);
    }
  }
  for (int i = 1; i + b - 1 <= n; i++) {
    for (int j = 1; j + a - 1 <= m; j++) {
      int cnt = 0;
      for (int k = i; k <= i + b - 1; k++) {
        for (int l = j; l <= j + a - 1; l++) {
          cnt += w[k][l];
        }
      }
      ans = min(ans, cnt);
    }
  }
  cout << ans << endl;
  return 0;
}
