There is an N×M grid. Each cell holds one number between 1 and K. The cell in row i and column j (1≤i≤N, 1≤j≤M) is written as (i,j).
A rectangle is fixed by four integers x1, y1, x2, y2 with 1≤x1≤x2≤N and 1≤y1≤y2≤M, and it consists of every cell (x,y) with x1≤x≤x2 and y1≤y≤y2. Its size is (x2−x1+1)×(y2−y1+1). Two rectangles are different when the values [x1,y1,x2,y2] differ.
Let Ck,n,m be the number of rectangles of size n×m in the grid that hold exactly k kinds of numbers. Write a program that computes every Ck,n,m.
For example, let N=M=K=3 and let the numbers be written as in the picture below.

With x1=2, y1=1, x2=3, y2=2, the four cells (2,1), (2,2), (3,1), (3,2) belong to one rectangle. Taken on its own, that rectangle looks like this.

Only 1 and 2 appear in it, so it is a rectangle with two kinds of numbers.