#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int mod=998244353;
int n,m,k,ans;
void update(int &x,int y) {
	x+=y; if (x>=mod) x-=mod;
}

int ksm(int x,int y) {
	int res=1;
	while (y) {
		if (y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod; y>>=1;
	} return res;
}

int main() {
	//freopen("1.txt","r",stdin);
	read(n),read(m),read(k);
	if (n==1) { printf("%d\n",ksm(k,m)); return 0; }
	if (m==1) { printf("%d\n",ksm(k,n)); return 0; }
	for (int i=1;i<=k;i++) {
		update(ans,(ll)ksm(k-i+1,m)*(ksm(i,n)-ksm(i-1,n)+mod)%mod);
	}
	printf("%d\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Integer overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=2e3+5;
ll dp[maxn][maxn],sum[3][maxn*2],belong[maxn][maxn];
char buff[maxn][maxn];
const int mod=1e9+7;
int main() {
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>(buff[i]+1);
    for(int i=1;i<=m;i++) belong[1][i]=i;
    for(int i=2;i<=n;i++) belong[i][1]=m+i-1;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            if(belong[i][j]) continue;
            belong[i][j]=belong[i-1][j-1];
        }
    }
    dp[1][1]=1;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            if(buff[i][j]=='#') {
                sum[0][belong[i][j]]=sum[1][i]=sum[2][j]=0;
            }else {
                if(i!=1||j!=1) dp[i][j]=(sum[0][belong[i][j]]+sum[1][i]+sum[2][j])%mod;
                (sum[0][belong[i][j]]+=dp[i][j])%=mod;
                (sum[1][i]+=dp[i][j])%=mod;
                (sum[2][j]+=dp[i][j])%=mod;
            }
        }
    }
    cout<<dp[n][m]%mod<<endl;
    return 0;
}