#include <bits/stdc++.h>
using namespace std;
long long n, m, a, b, c[52][52], sum[52][52];
signed main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) cin >> c[i][j];
  cin >> a >> b;
  memset(sum, 0, sizeof(sum));
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) sum[i][j] = sum[i][j - 1] + c[i][j];
  long long ans = a * b;
  for (long long i = 1; i <= n - a + 1; i++) {
    for (long long j = 1; j <= m - b + 1; j++) {
      long long cnt = 0;
      for (long long ii = i; ii < i + a; ii++)
        cnt += sum[ii][j + b - 1] - sum[ii][j - 1];
      ans = min(cnt, ans);
    }
  }
  for (long long i = 1; i <= n - b + 1; i++) {
    for (long long j = 1; j <= m - a + 1; j++) {
      long long cnt = 0;
      for (long long ii = i; ii < i + b; ii++)
        cnt += sum[ii][j + a - 1] - sum[ii][j - 1];
      ans = min(cnt, ans);
    }
  }
  cout << ans;
  return 0;
}
