#include <bits/stdc++.h>
using namespace std;
int mas[50][50], n, m, a, b, sum, minim = 1000000000;
int main() {
  cin >> n >> m;
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (m); ++j) cin >> mas[i][j];
  cin >> a >> b;
  for (int i = 0; i < (n - a + 1); ++i)
    for (int j = 0; j < (m - b + 1); ++j) {
      sum = 0;
      for (int k = 0; k < (a); ++k)
        for (int l = 0; l < (b); ++l) sum += mas[i + k][j + l];
      minim = ((minim) < (sum) ? (minim) : (sum));
    }
  for (int i = 0; i < (n - b + 1); ++i)
    for (int j = 0; j < (m - a + 1); ++j) {
      sum = 0;
      for (int k = 0; k < (a); ++k)
        for (int l = 0; l < (b); ++l) sum += mas[i + l][j + k];
      minim = ((minim) < (sum) ? (minim) : (sum));
    }
  cout << minim;
  return 0;
}
