#include <bits/stdc++.h>
using namespace std;
using namespace std;
int a[60][60], n, m, s[60][60], x, y;
void solve(void);
int main(void) {
  solve();
  return 0;
}
void solve(void) {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      s[i][j] = a[i][j] + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    }
  }
  cin >> x >> y;
  int minn = 3600;
  for (int i = x; i <= n; i++) {
    for (int j = y; j <= m; j++) {
      int temp = s[i][j] - s[i - x][j] - s[i][j - y] + s[i - x][j - y];
      minn = minn < temp ? minn : temp;
    }
  }
  for (int i = y; i <= n; i++) {
    for (int j = x; j <= m; j++) {
      int temp = s[i][j] - s[i - y][j] - s[i][j - x] + s[i - y][j - x];
      minn = minn < temp ? minn : temp;
    }
  }
  cout << minn << endl;
}
