Entanglement

아직 제출이 없습니다시간 제한3초메모리 제한256 MB

문제

Consider an array AA of length NN and an array BB of length MM. An entanglement of these two arrays is a matrix CC of size N×MN \times M such that for all 0iN10 \le i \le N - 1 and 0jM10 \le j \le M - 1, at least one of the following conditions holds: C\[i]\[j]=A\[i]C\[i]\[j] = A\[i] or C\[i]\[j]=B\[j]C\[i]\[j] = B\[j].

You are given a matrix CC of size N×MN \times M and a number KK. Your task is to count the number of pairs of arrays (A,B)(A, B) such that:

  • AA has length NN.
  • BB has length MM.
  • AA and BB consist of values from the set 1,2,,K\\{1, 2, \ldots, K\\}.
  • CC is an entanglement of AA and BB.

Print the number of such pairs modulo 109+710^9 + 7.

입력

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

Each of the following NN lines contains MM integers separated by spaces, the jj-th number on the ii-th of these lines is C\[i1]\[j1]C\[i - 1]\[j - 1].

출력

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