Score : 500 points
Problem Statement
You have a grid with H rows from top to bottom and W columns from left to right.
We denote by (i,j) the square at the i-th row from the top and j-th column from the left.
(i,j) (1≤i≤H,1≤j≤W) has an integer Ai,j between 1 and N written on it.
You are given integers h and w. For all pairs (k,l) such that 0≤k≤H−h and 0≤l≤W−w, solve the following problem:
- If you black out the squares (i,j) such that k<i≤k+h and l<j≤l+w, how many distinct integers are written on the squares that are not blacked out?
Note, however, that you do not actually black out the squares (that is, the problems are independent).
Constraints
- 1≤H,W,N≤300
- 1≤h≤H
- 1≤w≤W
- (h,w)=(H,W)
- 1≤Ai,j≤N (1≤i≤H,1≤j≤W)
- All values in the input are integers.
The input is given from Standard Input in the following format:
H W N h w
A1,1 A1,2 … A1,W
A2,1 A2,2 … A2,W
⋮
AH,1 AH,2 … AH,W
Output
Print the answers in the following format, where ansk,l denotes the answer to (k,l):
ans0,0 ans0,1 … ans0,W−w
ans1,0 ans1,1 … ans1,W−w
⋮
ansH−h,0 ansH−h,1 … ansH−h,W−w
The given grid is as follows:

For example, when (k,l)=(0,0), four distinct integers 1,3,4, and 5 are written on the squares that are not blacked out, so 4 is the answer.