Under construction

Still being built. Things may change

Entanglement

Time limit3sMemory limit256 MB

Summary
Count pairs of arrays A (length N) and B (length M) with values from 1 to K such that every cell C[i][j] equals A[i] or B[j].
Level

Hard9 of 10

Topics
Combinatorics, Graph, Math
Solved
No attempts yet

Problem

Consider an array AA of length NN and an array BB of length MM. An entanglement of these two arrays is an N×MN \times M matrix CC such that for every 0≤i≤N−10 \le i \le N - 1 and 0≤j≤M−10 \le j \le M - 1, at least one of C[i][j]=A[i]C[i][j] = A[i] or C[i][j]=B[j]C[i][j] = B[j] holds.

You are given a matrix CC of size N×MN \times M and an integer KK. Count the pairs of arrays (A,B)(A, B) such that:

  • AA has length NN.
  • BB has length MM.
  • Every element of AA and BB is in {1,2,…,K}\{1, 2, \ldots, K\}.
  • CC is an entanglement of AA and BB.

Print the count modulo 109+710^9 + 7.

Input

The first line contains three integers NN, MM, and KK (1≤N,M≤3001 \le N, M \le 300, 1≤K≤N×M1 \le K \le N \times M).

Each of the next NN lines contains MM integers separated by spaces. The jj-th number on the ii-th of these lines is C[i−1][j−1]C[i-1][j-1].

Output

Print a single integer: the number of pairs (A,B)(A, B) modulo 109+710^9 + 7.

Examples1

  1. Example 1

    Input
    2 2 2
    1 1
    1 2
    
    Expected output
    5