// Arup Guha
// Solution to 2015 February USACO Silver Problem: Cow Hopscotch
// Originally written sometime in 2015, fixed on 5/10/2018

import java.util.*;
import java.io.*;

public class hopscotch {

    final public static long MOD = 1000000007L;

	public static void main(String[] args) throws Exception {

		Scanner stdin = new Scanner(new File("hopscotch.in"));
		FileWriter fout = new FileWriter(new File("hopscotch.out"));

		// Read in the grid.
		int r = stdin.nextInt();
		int c = stdin.nextInt();
		int k = stdin.nextInt();
		int[][] grid = new int[r][c];
		for (int i=0; i<r; i++)
            for (int j=0; j<c; j++)
                grid[i][j] = stdin.nextInt();

		// Set up our DP.
		long[][] dp = new long[r][c];
		dp[0][0] = 1;
		for (int i=0; i<r; i++) {
			for (int j=0; j<c; j++) {

				// Here is everywhere we can go.
				for (int dx=1; i+dx<r; dx++)
					for (int dy=1; j+dy<c; dy++)
						if (grid[i][j] != grid[i+dx][j+dy])
							dp[i+dx][j+dy] = (dp[i+dx][j+dy]+dp[i][j])%MOD;
			}
		}
		
		// This is our answer.
		fout.write(dp[r-1][c-1]+"\n");

		stdin.close();
		fout.close();
	}
}
