#include <cstdio>

char str[16][16];
int n, m;
int result;


#define TEST(dx,dy) { if ( str[y + dy][x + dx] == '.'  ) DFS( x + dx, y + dy );}
void DFS( int x, int y ) {
  if ( x == m-2 && y == n-1 ) { ++result; return; }
  str[y][x] = '$';
  TEST( -1, 0 );
  TEST( 1, 0 );
  TEST( 0, -1 );
  TEST( 0, 1 );

  str[y][x] = '.';
}

int main(void) {
  scanf("%d%d", &n, &m);
  
  for ( int j = 0; j < m+2; ++j )
    str[0][j] = str[n+1][j] = '#';
  for ( int i = 1; i <= n; ++i ) {
    scanf("%s", str[i] + 1);
    str[i][0] = str[i][m+1] = '#';
  }
  n += 2;
  m += 2;
  
  str[0][1] = '.';
  str[n-1][m-2] = '.';
  
  DFS( 0, 0 );
  
  printf("%d\n", result % 10007);
  
  return 0;
}
