#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int board[50 + 5][50 + 5];
  while (cin >> n >> m) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        scanf("%d", &board[i][j]);
      }
    }
    int a, b;
    cin >> a >> b;
    int res = 0x3f3f3f3f;
    for (int i = 1; i + a - 1 <= n; i++) {
      for (int j = 1; j + b - 1 <= m; j++) {
        int ans = 0;
        for (int k = i; k <= i + a - 1; k++) {
          for (int l = j; l <= j + b - 1; l++) {
            ans += board[k][l];
          }
        }
        res = min(res, ans);
      }
    }
    swap(a, b);
    for (int i = 1; i + a - 1 <= n; i++) {
      for (int j = 1; j + b - 1 <= m; j++) {
        int ans = 0;
        for (int k = i; k <= i + a - 1; k++) {
          for (int l = j; l <= j + b - 1; l++) {
            ans += board[k][l];
          }
        }
        res = min(res, ans);
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
