#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int garden[n][k];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      cin >> garden[i][j];
    }
  }
  int a, b;
  cin >> a >> b;
  int mn = 1000000000;
  for (int i = 0; i <= n - a; i++) {
    for (int j = 0; j <= k - b; j++) {
      int sum = 0;
      for (int k = i; k < i + a; k++) {
        for (int l = j; l < j + b; l++) {
          sum += garden[k][l];
        }
      }
      mn = min(sum, mn);
    }
  }
  for (int i = 0; i <= n - b; i++) {
    for (int j = 0; j <= k - a; j++) {
      int sum = 0;
      for (int k = i; k < i + b; k++) {
        for (int l = j; l < j + a; l++) {
          sum += garden[k][l];
        }
      }
      mn = min(sum, mn);
    }
  }
  cout << mn << '\n';
  return 0;
}
