#include <bits/stdc++.h>
using namespace std;
void SADIEM() {
  std::ios_base::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
}
int n, m;
vector<vector<long long>> v;
void pre() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      v[i][j] += v[i][j - 1];
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      v[i][j] += v[i - 1][j];
    }
  }
}
long long MIN(int a, int b) {
  long long ans = INT_MAX, sum;
  a--, b--;
  for (int i = 1; i + a <= n; i++) {
    for (int j = 1; j + b <= m; j++) {
      sum =
          v[i + a][j + b] - v[i - 1][j + b] - v[i + a][j - 1] + v[i - 1][j - 1];
      ans = min(ans, sum);
    }
  }
  return ans;
}
int main() {
  SADIEM();
  int a, b;
  cin >> n >> m;
  v.resize(n + 2, vector<long long>(m + 2));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> v[i][j];
    }
  }
  pre();
  cin >> a >> b;
  cout << min(MIN(a, b), MIN(b, a));
}
