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
//package codeforces.archive;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Problem293B {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    int[] readInts() throws IOException {
        String line = reader.readLine();
        String []s = line.split(" ");
        int[] ret = new int[s.length];
        for(int i = 0; i < s.length; i++) {
            ret[i] = Integer.parseInt(s[i]);
        }
        return ret;
    }

    int[] tt = null;
    int ti = 0;
    int readInt() throws IOException {
        if(tt == null || ti == tt.length) {
            tt = readInts();
            ti = 0;
        }
        return tt[ti++];
    }

    void solve() throws IOException {
        final int rows = readInt();
        final int cols = readInt();
        final int colors = readInt();
        if(rows + cols - 1 > colors) {
            writer.println(0);
            writer.flush();
            return;
        }
        final int[][] board = new int[rows][];
        for(int i = 0; i < rows; i++) {
            board[i] = readInts();
        }
        class Colorer {
            int[] cmap = new int[colors + 1];
            int[] ccnt = new int[colors + 1];
            boolean[] taken = new boolean[colors + 1];
            int free = colors;
            final int MOD = 1000 * 1000 * 1000 + 7;
            int[] f = new int[colors + 1];
            int[][] C = new int[colors + 1][colors + 1];
            {
                f[0] = 1;
                for(int i = 1; i <= colors; i++) {
                    f[i] = mult(f[i - 1], i);
                }
                for(int n = 0; n <= colors; n++) {
                    C[n][0] = 1;
                    for(int k = 1; k <= n; k++) {
                        C[n][k] = add(C[n - 1][k], C[n - 1][k - 1]);
                    }
                }
            }
            int[][] msk = new int[rows][cols];

            final int add(int x, int y) {
                x += y;
                return x >= MOD ? x - MOD : x;
            }
            final int mult(int x, int y) {
                return (int)((long) x * y % MOD);
            }
            final boolean bitSet(int x, int bit) {
                return (x & (1 << bit)) > 0;
            }

            int color(int r, int c, int used) {
                if(c == cols) {
                    return color(r + 1, 0, used);
                }
                if(r == rows) {
                    return mult(C[free][free - colors + used], f[free - colors + used]);
                }
                int mask = (r > 0 ? msk[r - 1][c] : 0) | (c > 0 ? msk[r][c - 1] : 0);
                if(board[r][c] > 0) {
                    int cl = board[r][c];
                    if(cmap[cl] > 0) {
                        if(bitSet(mask, cmap[cl])) return 0;
//                        ccnt[cl]++;
                        msk[r][c] = mask | (1 << cmap[cl]);
                        int res = color(r, c + 1, used);
//                        ccnt[cl]--;
                        return res;
                    }
                    int res = 0;
                    for(int i = 1; i <= used; i++) {
                        if(!bitSet(mask, i) && !taken[i]) {
                            cmap[cl] = i;
                            taken[i] = true;
                            free--;
                            msk[r][c] = mask | (1 << i);
                            res = add(res, color(r, c + 1, used));
                            cmap[cl] = 0;
                            taken[i] = false;
                            free++;
                        }
                    }
                    if(used < colors) {
                        cmap[cl] = used + 1;
                        taken[used + 1] = true;
                        free--;
                        msk[r][c] = mask | (1 << used + 1);
                        res = add(res, color(r, c + 1, used + 1));
                        cmap[cl] = 0;
                        taken[used + 1] = false;
                        free++;
                    }
                    return res;
                }
                else {
                    int res = 0;
                    for(int i = 1; i <= used; i++) {
                        if(!bitSet(mask, i)) {
                            msk[r][c] = mask | (1 << i);
                            res = add(res, color(r, c + 1, used));
                        }
                    }
                    if(used < colors) {
                        msk[r][c] = mask | (1 << used + 1);
                        res = add(res, color(r, c + 1, used + 1));
                    }
                    return res;
                }
            }


        }

        writer.println(new Colorer().color(0, 0, 0));
        writer.flush();
    }

    public static void main(String[] args) throws IOException {
        new Problem293B().solve();
    }
}
