Carefree Millionaire and the Opera House

View as PDF

Submit solution

Points: 18
Time limit: 1.0s
Memory limit: 256M

Problem types

Carefree millionaire Anu Uno wants to spend some of her spare money, so she asks the help of her real estate agent Oxi. Oxi shows her a map of a housing estate consisting of \(\mathbf{N}\) rows and \(\mathbf{M}\) columns of houses, asks her to choose which houses to buy. Anu tells Oxi the minimum amount she wants to spend, \(\mathbf{A}\), and the maximum amount she wants to spend, \(\mathbf{B}\), and leaves him to buy some houses for her. But Anu has something else in her mind, she wants to take down all the buildings she will buy and build a rectangular or square opera house. So:

  • All the houses that Oxi will buy for Anu must be in the same rectangle or square,
  • All the houses in this rectangle or square must be bought by Oxi,
  • Total money spent on the houses must at least be equal to the minimum amount of \(\mathbf{A}\) and the maximum amount \(\mathbf{B}\).

Your task is to find how many such rectangle or squares are there in this housing estate to satisfy Anu's needs for an opera house. Note that for two rectangle or squares to differ, it's enough for them to be placed on the map differently.

Input

The first line contains two integers \(\mathbf{N}\) and \(\mathbf{M}\) separated by a single space.

The following \(\mathbf{N}\) lines describes the map of the housing estate, where each value corresponds to the value of the house in that position. Each line consists of \(\mathbf{M}\) integers seperated by single spaces.

The last line contains two integers \(\mathbf{A}\) and \(\mathbf{B}\), minimum and maximum amount respectively, separated by a single space.

Output

Count of squares or rectangles that satisfies Anu's needs for an opera house.

Constraints

  • \(1 ≤ \mathbf{N} \cdot \mathbf{M} ≤ 10^5\)
  • \(0 ≤ \mathbf{A} ≤ \mathbf{B} ≤ 10^{18}\)
  • The minimum possible cost for any house is \(0\) and the maximum possible cost is \(10^9\).

Examples

Input:

3 4
1 1 1 1
1 1 1 1
1 1 1 1
12 12

Output:

1

Input:

2 3
1 2 3
4 5 2
4 5

Output:

5