#include <bits/stdc++.h>
using namespace std;
int x[100][100];
int main() {
  int n, m, a, b, i, j, k, l, c = 0, min = 2500;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) cin >> x[i][j];
  }
  cin >> a >> b;
  for (i = 0; i <= n - a; i++) {
    for (j = 0; j <= m - b; j++) {
      c = 0;
      for (k = i; k < i + a; k++) {
        for (l = j; l < j + b; l++) {
          c = c + x[k][l];
        }
      }
      if (c < min) {
        min = c;
      }
    }
  }
  for (i = 0; i <= n - b; i++) {
    for (j = 0; j <= m - a; j++) {
      c = 0;
      for (k = i; k < i + b; k++) {
        for (l = j; l < j + a; l++) {
          c = c + x[k][l];
        }
      }
      if (c < min) {
        min = c;
      }
    }
  }
  cout << min << endl;
  return 0;
}
