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.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	
	static final int MOD = 1000000007;
	
	int n, m, K;
	int a [][];
	int possible [][];
	int usedMask [][];
	int dp[][][];
	boolean usedDown[][][];
	int uColor[];
	
	long brute (int i, int j) {
		if (i == n) {
			return 1;
		}
		int uMask = 0;
		if (i > 0) uMask |= usedMask[i - 1][j];
		if (j > 0) uMask |= usedMask[i][j - 1];
		long result = 0;
		if (a[i][j] == -1) {
			long ans = -1;
			long ret = 0;
			for (int k = 0; k < possible[uMask].length; k++) {
				int color = possible[uMask][k];
				if (usedDown[i][j][color]) continue;
				if (ans != -1 && uColor[color] == 0) {
					result += ans;
					continue;
				}
				usedMask[i][j] = uMask | (1 << color);
				uColor[color]++;
				if (j + 1 == m) {
					ret = brute (i + 1, 0);
					result += ret;
					if (uColor[color] == 1)
						ans = ret;
				} else {
					ret = brute (i, j + 1);
					result += ret;
					if (uColor[color] == 1)
						ans = ret;
				}
				uColor[color]--;
			}
		} else {
			if ((uMask & (1 << a[i][j])) == 0) {
				if (!usedDown[i][j][a[i][j]]) { 
					usedMask[i][j] = uMask | (1 << a[i][j]);
					uColor[a[i][j]]++;
					if (j + 1 == m)
						result += brute (i + 1, 0);
					else
						result += brute (i, j + 1);
					uColor[a[i][j]]--;
				}
			}
		}
		return result % MOD;
	}
	

	public void solve() throws Throwable {
		n = sc.nextInt();
		m = sc.nextInt();
		K = sc.nextInt();
		a = new int [n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				a[i][j] = sc.nextInt() - 1;
			}
		}
		if (n + m - 1 > K) {
			out.println(0);
			return;
		}
		possible = new int [(1 << K)][];
		for (int mask = 0; mask < (1 << K); mask++) {
			int bits = K - Integer.bitCount(mask);
			possible[mask] = new int [bits];
			for (int j = 0, it = 0; j < K; j++) {
				if (((1 << j) & mask) == 0)
					possible[mask][it++] = j;
			}
		}
		usedMask = new int [n][m];
		usedDown = new boolean [n][m][K];
		uColor = new int [K];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (a[i][j] != -1) {
					uColor[a[i][j]]++;
					for (int ii = 0; ii <= i; ii++) {
						for (int jj = 0; jj <= j; jj++) {
							if (ii == i && jj == j) continue;
							usedDown[ii][jj][a[i][j]] = true;
						}
					}
				}
			}
		}
		long answer = brute(0, 0);
		out.println(answer);
	}

	BufferedReader in;
	PrintWriter out;
	FastScanner sc;

	static Throwable uncaught;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Solution.uncaught = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread t = new Thread(null, new Solution(), "", (1 << 26));
		t.start();
		t.join();
		if (uncaught != null) {
			throw uncaught;
		}
	}

}

class FastScanner {

	BufferedReader reader;
	StringTokenizer strTok;

	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}

	public String nextToken() throws IOException {
		while (strTok == null || !strTok.hasMoreTokens()) {
			strTok = new StringTokenizer(reader.readLine().trim());
		}
		return strTok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

}