#include <bits/stdc++.h>
int main() {
  int n, m, a, b;
  int s[50][50];
  int t, r(1 << 30);
  std::scanf("%d%d", &n, &m);
  for (int i(0); i < n; ++i) {
    for (int j(0); j < m; ++j) std::scanf("%d", &s[i][j]);
  }
  std::scanf("%d%d", &a, &b);
  for (int x(0); x < 2; ++x) {
    for (int i(0); i + a <= n; ++i) {
      for (int j(0); j + b <= m; ++j) {
        t = 0;
        for (int h(0); h < a; ++h) {
          for (int k(0); k < b; ++k) t += s[i + h][j + k];
        }
        r = std::min(r, t);
      }
    }
    std::swap(a, b);
  }
  std::printf("%d\n", r);
  return 0;
}
