#include <bits/stdc++.h>
using namespace std;
const int inf = 1999999999;
const double pi = acos(-1.0);
const double eps = 1e-10;
char gc() {
  char c;
  while (isspace(c = getchar()))
    ;
  return c;
}
int t[100][100];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &t[i][j]);
  int a, b;
  scanf("%d%d", &a, &b);
  int mn = inf;
  for (int i = 0; i + a <= n; i++)
    for (int j = 0; j + b <= m; j++) {
      int s = 0;
      for (int x = i; x < i + a; x++)
        for (int y = j; y < j + b; y++) s += t[x][y];
      mn = min(s, mn);
    }
  for (int i = 0; i + b <= n; i++)
    for (int j = 0; j + a <= m; j++) {
      int s = 0;
      for (int x = i; x < i + b; x++)
        for (int y = j; y < j + a; y++) s += t[x][y];
      mn = min(s, mn);
    }
  printf("%d\n", mn);
}
