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 static java.util.Arrays.deepToString;

import java.io.*;
import java.math.*;
import java.util.*;

public class B {
	static int n, m, k;
	static int MOD = 1000000007;
	static long ans;
	static int[] fact;
	static int[][] B;

	static int get(int[][] pattern) {
		int[] whoP = new int[k + 1];
		int haveMsk = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int p = pattern[i][j];
				haveMsk |= 1 << p;
				if (B[i][j] != 0) {
					if (whoP[p] != 0 && whoP[p] != B[i][j]) {
						return 0;
					}
					whoP[p] = B[i][j];
				}
			}
		}
		int total = k, have = Integer.bitCount(haveMsk);
		boolean[] used = new boolean[k + 1];
		for (int c = 1; c <= k; c++) {
			if (whoP[c] > 0) {
				if (used[whoP[c]]) {
					return 0;
				}
				have--;
				total--;
				used[whoP[c]] = true;
			}
		}
		return fact[total] / fact[total - have];
	}

	static void go(int[][] b, int x, int y, int usedC, int newC) {
		if (y == n) {
			ans += get(b);
			return;
		}
		int nx = x + 1, ny = y;
		if (nx == m) {
			nx = 0;
			ny++;
		}
		int bad = 0;
		for (int row = 0; row < y; row++) {
			for (int col = 0; col <= x; col++) {
				bad |= 1 << (b[row][col]);
			}
		}
		for (int col = 0; col < x; col++) {
			bad |= 1 << (b[y][col]);
		}
		if (b[y][x] != 0) {
			if (((bad >> b[y][x]) & 1) == 0)
				go(b, nx, ny, usedC, newC);
			return;
		}
		boolean q = false;
		for (int take = 1; take <= k; take++) {
			if (((bad >> take) & 1) != 0)
				continue;
			if (((usedC >> take) & 1) != 0) {
				b[y][x] = take;
				go(b, nx, ny, usedC, newC);
				b[y][x] = 0;
			} else if (!q) {
				b[y][x] = take;
				go(b, nx, ny, usedC | (1 << take), newC + 1);
				b[y][x] = 0;
				q = true;
			}
		}
	}

	static void solve() {
		n = nextInt();
		m = nextInt();
		k = nextInt();
		int[][] b = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				b[i][j] = nextInt();
			}
		}
		setTime();
		solve(b, k);
		writer.println(ans % MOD);
	}

	static void solve(int[][] b, int _k) {
		B = b;
		n = b.length;
		m = b[0].length;
		k = _k;
		ans = 0;
		if (n + m - 1 > k) {
			return;
		}
		int usedC = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (b[i][j] > 0) {
					usedC |= 1 << b[i][j];
				}
			}
		}
		go(new int[n][m], 0, 0, 0, 0);
	}

	static void test() {
		for (int n = 1; n <= 10; n++) {
			for (int m = 1; m <= 10; m++) {
				solve(new int[n][m], 10);
				debug(n, m, ans);
			}
		}
	}

	public static void main(String[] args) throws Exception {
		reader = new BufferedReader(new InputStreamReader(System.in));
		writer = new PrintWriter(System.out);

		fact = new int[11];
		fact[0] = 1;
		for (int i = 1; i < fact.length; i++) {
			fact[i] = fact[i - 1] * i;
		}

		// test();

		setTime();
		solve();
		printTime();
		printMemory();

		writer.close();
	}

	static BufferedReader reader;
	static PrintWriter writer;
	static StringTokenizer tok = new StringTokenizer("");
	static long systemTime;

	static void debug(Object... o) {
		System.err.println(deepToString(o));
	}

	static void setTime() {
		systemTime = System.currentTimeMillis();
	}

	static void printTime() {
		System.err.println("Time consumed: " + (System.currentTimeMillis() - systemTime));
	}

	static void printMemory() {
		System.err.println("Memory consumed: "
				+ (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000 + "kb");
	}

	static String next() {
		while (!tok.hasMoreTokens()) {
			String w = null;
			try {
				w = reader.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (w == null)
				return null;
			tok = new StringTokenizer(w);
		}
		return tok.nextToken();
	}

	static int nextInt() {
		return Integer.parseInt(next());
	}

	static long nextLong() {
		return Long.parseLong(next());
	}

	static double nextDouble() {
		return Double.parseDouble(next());
	}

	static BigInteger nextBigInteger() {
		return new BigInteger(next());
	}
}