#include <bits/stdc++.h>
using namespace std;
long long get() {
  char c = getchar();
  long long x = 0LL;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x *= 10LL;
    x += (c - '0');
    c = getchar();
  }
  return x;
}
string i_t_s(int x) {
  string t = "";
  while (x) {
    t += x % 10 + '0';
    x /= 10;
  }
  reverse(t.begin(), t.end());
  return t;
}
int s_t_i(string t) {
  int x = 0;
  for (int i = 0; i < (int)(t.size()); i++) {
    x = x * 10 + (t[i] - '0');
  }
  return x;
}
long long q_p(long long x, long long y) {
  long long res = 1;
  x %= 1000000007;
  while (y) {
    if (y % 2) {
      res = res * x;
      res %= 1000000007;
    }
    y /= 2;
    x = x * x;
    x %= 1000000007;
  }
  return res;
}
int n, m, a, b;
int x[101][101];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> x[i][j];
    }
  cin >> a >> b;
  int ans = n * m;
  for (int i = 0; i < n - a + 1; i++)
    for (int j = 0; j < m - b + 1; j++) {
      int now = 0;
      for (int i1 = i; i1 < i + a; i1++)
        for (int j1 = j; j1 < j + b; j1++) now += x[i1][j1];
      ans = min(ans, now);
    }
  for (int i = 0; i < n - b + 1; i++)
    for (int j = 0; j < m - a + 1; j++) {
      int now = 0;
      for (int i1 = i; i1 < i + b; i1++)
        for (int j1 = j; j1 < j + a; j1++) now += x[i1][j1];
      ans = min(ans, now);
    }
  cout << ans;
  return 0;
}
