#include <cstdio>

using namespace std;

bool bio[11][11];
const int mod = 10007;
int sol, R, S;
char P[11][11];
void brut(int rr, int ss)
{
    if (rr<0 || ss<0 || rr>=R || ss>=S || bio[rr][ss]|| P[rr][ss] == '#') return;
    if (rr==R-1 && ss == S-1) {
        sol++;
        while (sol>=mod) sol-=mod;
        return;
    }
    bio[rr][ss] = true;
    brut(rr +1, ss);
    brut(rr -1, ss);
    brut(rr , ss+1);
    brut(rr , ss-1);
    bio[rr][ss] = false;
}
int main()
{
sol = 0;
scanf("%d%d", &R, &S);
for (int i=0; i<R; i++)
for (int j=0; j<S; j++)
scanf(" %c", &P[i][j]);
brut(0,0);
printf("%d\n", sol);
}
