#include <bits/stdc++.h>
int main() {
  int map[55][55];
  int n, m, a, b;
  int i, j;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &map[i][j]);
    }
  }
  scanf("%d%d", &a, &b);
  int sum = 0, k, p;
  int min = 999999;
  for (i = 0; i + b <= n; i++) {
    for (j = 0; j + a <= m; j++) {
      sum = 0;
      for (k = i; k < i + b; k++) {
        for (p = j; p < j + a; p++) {
          sum += map[k][p];
        }
      }
      if (sum < min) min = sum;
    }
  }
  for (i = 0; i + a <= n; i++) {
    for (j = 0; j + b <= m; j++) {
      sum = 0;
      for (k = i; k < i + a; k++) {
        for (p = j; p < j + b; p++) {
          sum += map[k][p];
        }
      }
      if (sum < min) min = sum;
    }
  }
  printf("%d\n", min);
  return 0;
}
