Cow Hopscotch

No attempts yetTime limit1sMemory limit256 MB

Problem

Farmer John's cows copied the human game of hopscotch and invented a version of their own. Animals that weigh close to a ton play it, so a round usually ends in a mess, and the cows still gather for it almost every afternoon.

The board is an R×CR \times C grid, and every square holds one integer between 11 and KK.

A cow starts on the top left square and reaches the bottom right square with a sequence of jumps. A jump from the current square to another square is allowed when all three conditions hold.

  1. The square you jump to holds an integer different from the integer on the current square.
  2. The square you jump to is at least one row below the current square.
  3. The square you jump to is at least one column to the right of the current square.

Count the different sequences of valid jumps that take a cow from the top left square to the bottom right square. Two sequences count as different when the lists of visited squares differ.

Input

The first line contains RR, CC, and KK. (2R7502 \le R \le 750, 2C7502 \le C \le 750, 1KR×C1 \le K \le R \times C)

Each of the next RR lines contains CC integers, all between 11 and KK.

Output

Print the number of ways to get from the top left square to the bottom right square, modulo 10000000071000000007.