#include<bits/stdc++.h>
usingnamespacestd;template<typenametype>inlinevoidread(type&num){num=0;boolflag=0;charch=getchar();while(!(ch>='0'&&ch<='9'))flag=(ch=='-'),ch=getchar();while(ch>='0'&&ch<='9')num=(num<<1)+(num<<3)+(ch^'0'),ch=getchar();num=(flag?-num:num);}template<typenametype>inlinevoidwrite(typenum){if(num==0){putchar('0');return;}charsta[30];shorttop=-1;if(num<0)putchar('-');while(num!=0)sta[++top]=(char)(num%10<0?-(num%10):num%10),num/=10;while(top>=0)putchar(sta[top]+'0'),top--;}#define M 1000000007
intr,c,k;intmaps[101][101],f[101][101];inlinevoiddp(){f[1][1]=1;for(inti=1;i<=r;i++){for(intj=1;j<=c;j++){if(i==1&&j==1)continue;for(intk=1;k<i;k++){for(intl=1;l<j;l++)if(maps[i][j]!=maps[k][l])f[i][j]=(f[i][j]+f[k][l])%M;}}}}intmain(){read(r),read(c),read(k);for(inti=1;i<=r;i++){for(intj=1;j<=c;j++)read(maps[i][j]);}dp();write(f[r][c]);return0;}