#include <bits/stdc++.h>
using namespace std;
int sum[55][55];
int MAP[55][55];
int n, m;
int a, b;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &MAP[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + MAP[i][j];
  int ans = 0X3F3F3F3F;
  scanf("%d %d", &a, &b);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      int r = i + a - 1;
      int c = j + b - 1;
      if (r <= n && c <= m)
        ans = min(
            ans, sum[r][c] - sum[r][j - 1] - sum[i - 1][c] + sum[i - 1][j - 1]);
      r = i + b - 1;
      c = j + a - 1;
      if (r <= n && c <= m)
        ans = min(
            ans, sum[r][c] - sum[r][j - 1] - sum[i - 1][c] + sum[i - 1][j - 1]);
    }
  printf("%d\n", ans);
  return 0;
}
