#include <bits/stdc++.h>
using namespace std;
void task();
int main() {
  srand(time(0));
  task();
  return 0;
}
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int M = 1e5 + 10;
int n, m;
int a[55][55];
void task() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", &a[i][j]);
  int x, y;
  scanf("%d %d", &y, &x);
  int ans = x * y;
  {
    for (int i = 0; i + x - 1 < n; ++i)
      for (int j = 0; j + y - 1 < m; ++j) {
        int buf = 0;
        for (int ii = 0; ii < x; ++ii)
          for (int jj = 0; jj < y; ++jj) buf += a[i + ii][j + jj];
        ans = min(ans, buf);
      }
  }
  {
    swap(x, y);
    for (int i = 0; i + x - 1 < n; ++i)
      for (int j = 0; j + y - 1 < m; ++j) {
        int buf = 0;
        for (int ii = 0; ii < x; ++ii)
          for (int jj = 0; jj < y; ++jj) buf += a[i + ii][j + jj];
        ans = min(ans, buf);
      }
  }
  printf("%d", ans);
}
