KPMATRIX  Matrix
The company you work in has got a secret job to do. Just a few persons know what it is all about. To keep a secret every programmer works on a small part of the project.
Your job is as follows. You are given a matrix of integer numbers with N rows and M columns. Also two integer numbers A and B are given. Your task is to find a number of submatrices of a given matrix with the sum of elements between A and B inclusively.
Input
The first line contains two integer numbers N and M (1 ≤ N, M ≤ 250). After that matrix description follows. N lines with M numbers each. The last line contains two integer numbers A and B (10^9 ≤ A ≤ B ≤ 10^9). All numbers separated with spaces. It's guaranteed that for every submatrix the absolute value of sum of it's elements will not exceed 10^9.
Output
Write to the output the number of submatrices of a given matrix with sum of their elements between A and B inclusively.
Example
Input: 3 3 1 0 0 0 1 0 0 0 1 1 3 Output: 26
hide comments
Palashvijay4O:
20160810 06:41:23
code running till 20th test case even if it is not working for smaller test cases. Please have a look into it. 

abdou_93:
20160318 20:04:37
O(n^3 log n) 

Noureldin Yosri:
20160316 19:43:07
don't take this problem seriously :3 

nour samir:
20140720 21:41:49
this problem is solvable by using segment tree and DP 

Hussain Kara Fallah:
20140103 09:25:19
I love this kind of problems


rajnish:
20120517 10:51:16
is there any other better algorithm other than o(n^2*m^2) 

Prabakaran:
20110221 20:48:00
hw is the output 26 for the above test case? 
Added by:  Pavel Kuznetsov 
Date:  20070223 
Time limit:  0.184s1.841s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO 
Resource:  IT Festival Arkhangelsk 2006 