#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e7 + 5;
const long long N = 1e9 + 7;
const long long mxN = 30000;
const double pi = 3.1415926536;
string alph = "abcdefghijklmnopqrstuvwxyz";
void solve() {
  long long n, m, cnt = 0, cnt1 = 0, mn = 1000000, mn1 = 100000000, mx1 = 0;
  cin >> n >> m;
  long long a[n][m];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  long long x, y;
  cin >> x >> y;
  for (long long i = 0; i < n - x + 1; i++) {
    for (long long j = 0; j < m - y + 1; j++) {
      cnt = 0;
      for (long long l = i; l < i + x; l++) {
        for (long long r = j; r < j + y; r++) {
          cnt += a[l][r];
        }
      }
      mn = min(mn, cnt);
    }
  }
  swap(x, y);
  for (long long i = 0; i < n - x + 1; i++) {
    for (long long j = 0; j < m - y + 1; j++) {
      cnt1 = 0;
      for (long long l = i; l < i + x; l++) {
        for (long long r = j; r < j + y; r++) {
          cnt1 += a[l][r];
        }
      }
      mn = min(mn, cnt1);
    }
  }
  cout << mn << "\n";
}
int32_t main() {
  solve();
  return 0;
}
