#include <bits/stdc++.h>
using namespace std;
int n, m, ar[51][51], a, b, ans, sum;
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  ans = 3000;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> ar[i][j];
  cin >> a >> b;
  for (int i = 0; i <= n - a; i++) {
    for (int j = 0; j <= m - b; j++) {
      sum = 0;
      for (int k = i; k < i + a; k++) {
        for (int l = j; l < j + b; l++) {
          sum += ar[k][l];
        }
      }
      ans = min(ans, sum);
    }
  }
  swap(a, b);
  for (int i = 0; i <= n - a; i++) {
    for (int j = 0; j <= m - b; j++) {
      sum = 0;
      for (int k = i; k < i + a; k++) {
        for (int l = j; l < j + b; l++) {
          sum += ar[k][l];
        }
      }
      ans = min(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}
