#include <bits/stdc++.h>
using namespace std;
int min(int &a, int &b) { return a < b ? a : b; }
int numTree(int uch[50][50], int &row, int &col, int &a, int &b, int &w,
            int &h) {
  int rowEnd = row + a;
  int colEnd = col + b;
  unsigned int res = 0;
  if (rowEnd > w || colEnd > h) {
    res = INT_MAX;
  } else {
    for (int rrow = row; rrow < rowEnd && rrow < w; rrow++) {
      for (int ccol = col; ccol < colEnd && ccol < h; ccol++) {
        res += uch[rrow][ccol];
      }
    }
  }
  rowEnd = row + b;
  colEnd = col + a;
  unsigned int res2 = 0;
  if (rowEnd > w || colEnd > h) {
    res2 = INT_MAX;
  } else {
    for (int rrow = row; rrow < rowEnd && rrow < w; rrow++) {
      for (int ccol = col; ccol < colEnd && ccol < h; ccol++) {
        res2 += uch[rrow][ccol];
      }
    }
  }
  return min(res, res2);
}
int main() {
  int n, m;
  scanf("%d", &n);
  ;
  scanf("%d", &m);
  ;
  int uch[50][50];
  memset(uch, 0, 50 * 50 * sizeof(int));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &uch[i][j]);
      ;
    }
  }
  int a, b;
  scanf("%d", &a);
  ;
  scanf("%d", &b);
  ;
  int minDer = INT_MAX;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int t = numTree(uch, i, j, a, b, n, m);
      if (t < minDer) minDer = t;
    }
  }
  printf("%d", minDer);
}
