#include <bits/stdc++.h>
using namespace std;
void build(vector<vector<int> > &v, int i, int j, int a, int b, int &mn) {
  if (i + a > v.size()) return;
  if (j + b > v[0].size()) return;
  a += i;
  b += j;
  int c = 0;
  for (int k = i; k < a; k++)
    for (int l = j; l < b; l++) c += v[k][l];
  mn = min(mn, c);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > v(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &v[i][j]);
    }
  }
  int a, b;
  cin >> a >> b;
  int mn = 1e8;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      build(v, i, j, a, b, mn);
      build(v, i, j, b, a, mn);
    }
  }
  cout << mn << endl;
  return 0;
}
