You have a rectangular n × m-cell board. Some cells are already painted some of k colors. You need to paint each uncolored cell one of the k colors so that any path from the upper left square to the lower right one doesn't contain any two cells of the same color. The path can go only along side-adjacent cells and can only go down or right.

Print the number of possible paintings modulo 1000000007 (109 + 7).

Input

The first line contains three integers n, m, k (1 ≤ n, m ≤ 1000, 1 ≤ k ≤ 10). The next n lines contain m integers each — the board. The first of them contains m uppermost cells of the board from the left to the right and the second one contains m cells from the second uppermost row and so on. If a number in a line equals 0, then the corresponding cell isn't painted. Otherwise, this number represents the initial color of the board cell — an integer from 1 to k.

Consider all colors numbered from 1 to k in some manner.

Output

Print the number of possible paintings modulo 1000000007 (109 + 7).

Examples

Input

2 2 4
0 0
0 0


Output

48


Input

2 2 4
1 2
2 1


Output

0


Input

5 6 10
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0


Output

3628800


Input

2 6 10
1 2 3 4 5 6
0 0 0 0 0 0


Output

4096
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Collections.*;

import static java.util.Collections.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.math.BigInteger.*;
import static java.lang.Character.*;

public class Main {

    void run(){
//        boolean oj = true;
//        boolean oj = false;


        Locale.setDefault(Locale.US);
        boolean oj = System.getProperty("ONLINE_JUDGE")!=null;

        String fileName = oj? "castle" : "dwarf";
        try {
            if( oj ){
                br = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }
            else{
                br  = new BufferedReader(new FileReader(fileName+".in" ));
                out = new PrintWriter   (new FileWriter(fileName+".out"));
            }
        } catch (Exception e) {
            MLE();
        }
        long tb = System.currentTimeMillis();
        solve();
        if( !oj )
            out.println("TIME: " + (System.currentTimeMillis() - tb) / 1e3) ;
        exit(0);
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    String next(){
        while( st==null || !st.hasMoreElements() ){
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                return null;
            }
        }
        return st.nextToken();
    }
    String nextLine(){
        try {
            return br.readLine();
        } catch (Exception e) {
            return null;
        }
    }
    int nextInt(){ return Integer.parseInt(next()); }
    double nextDouble(){ return Double.parseDouble(next()); }
    long nextLong(){ return Long.parseLong(next()); }

    void exit( int val ){
        out.flush();
        System.exit(val);
    }

    void MLE(){
        int[][] arr = new int[1024*1024][];
        for( int i = 0; i < 1024*1024; ++i )
            arr[i] = new int[1024*1024];
    }

    public static void main(String[] args) {
        new Main().run();
    }






    final long mod = (long)1e9 + 7;
    int n, m, k;
    int[][] grid, org;
    int cntOrgCol;
    boolean[] orgCol;
    long cntIter = 0;
    long ans = 0;
    long[] fact = new long[20];{
        fact[0] = 1;
        for( int i = 1; i < fact.length; ++i ){
            fact[i] = i * fact[i-1];
            fact[i] %= mod;
        }
    }

    void show(){
        for( int i = 0; i<n; ++i ){
            for( int j = 0; j < m; ++j )
                out.printf( "%2d", grid[i][j] );
            out.println();
        }
        out.println();
    }

    boolean haveSame( int ie, int je, int col ){
        for( int i = 0; i <= ie; ++i )
        for( int j = 0; j <= je; ++j ){
            if( i==ie && j==je ) return false;
            if( grid[i][j]==col ) return true;
        }
        MLE();
        return false;
    }

    boolean OK(){
        int[] newCol = new int[k+1];
        boolean[] curUsedCol = new boolean[k+1];
        for( int i = 0; i < n; ++i )
        for( int j = 0; j < m; ++j ){
            curUsedCol[grid[i][j]] = true;
            if( 0 < org[i][j] ){
                if( newCol[org[i][j]] == 0 )
                    newCol[org[i][j]] = grid[i][j];
                else if( newCol[org[i][j]] != grid[i][j] )
                    return false;
            }
        }
        for( int a =   1; a <= k; ++a )
        for( int b = a+1; b <= k; ++b )
            if( 0<newCol[a] && 0<newCol[b] && newCol[a]==newCol[b] )
                return false;
        for( int c = 1; c <= k; ++c )
            if( orgCol[c] && !curUsedCol[c] )
                return false;
        return true;
    }

    int[] cntUsed;
    void f( int i, int j ){
        if( j == m ){
            j = 0;
            ++i;
        }


        if( i == n ){
            if( OK() )
            {
                ++cntIter;

                int cntUsedCol = 0;
                for( int c = 1; c <= k; ++c )
                    if( 0 < cntUsed[c] )
                        ++cntUsedCol;
                ans += fact[cntUsedCol - cntOrgCol];
                ans %= mod;
//                out.println(cntIter);
//                out.println("ans: " + ans);
//                show();
            }
        }
        else{
            for( int c = 1; c <= k; ++c ){
                //
                boolean OK = true;
                if( cntUsed[c]==0 ){
                    for( int pr = 1; pr <= k; ++pr )
                        if( c < pr && 0 < cntUsed[pr] )
                            OK = false;
                }
                if( !OK ) continue;
                /**/
                if( haveSame(i,j,c) ) continue;

                ++cntUsed[c];
                grid[i][j] = c;

                f( i, j+1 );

                --cntUsed[c];
                grid[i][j] = 0;
            }
        }
    }


    void solve(){
        n = nextInt();
        m = nextInt();
        k = nextInt();
        if( k < m+n-1 ){
            out.println(0);
            return;
        }

        orgCol = new boolean[k+1];
        org = new int[n][m];
        for( int i = 0; i < n; ++i )
        for( int j = 0; j < m; ++j )
            orgCol[ org[i][j] = nextInt() ] = true;
        cntOrgCol = 0;
         for( int c = 1; c <= k; ++c )
             if( orgCol[c] )
                 ++cntOrgCol;

        grid = new int[n][m];
        cntUsed = new int[k+1];
        f( 0, 0 );
//        out.println( "cntIter: " + cntIter );
        out.println( ans );
    }




    void deb(){
    }


}