#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
  return x * f;
}
void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 100;
int n, m, a, b, sum[N][N];
int ans = 1000000000;
int S(int x1, int y1, int x2, int y2) {
  return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + read();
  a = read(), b = read();
  for (int x1 = 1; x1 <= n; x1++)
    for (int y1 = 1; y1 <= m; y1++) {
      int x2 = x1 + a - 1, y2 = y1 + b - 1;
      if (x2 <= n && y2 <= m) ans = min(ans, S(x1, y1, x2, y2));
      x2 = x1 + b - 1, y2 = y1 + a - 1;
      if (x2 <= n && y2 <= m) ans = min(ans, S(x1, y1, x2, y2));
    }
  print(ans), putchar('\n');
}
