sub mul{ my@C; ($C[$y=$_/100][$x=$_/10%10]+=$Z[$y][$_%=10]*$_[$_][$x])%=1e9+7for 0..999; @C } @@=( [1,1,1,1,1,1,1,1,0,0], [0,1,1,1,0,0,0,1,0,1], [0,1,1,1,1,1,0,0,0,1], [0,1,1,1,1,1,1,0,1,1], [0,0,1,1,1,1,0,0,0,1], [0,0,1,1,1,1,1,0,0,1], [0,0,0,1,0,1,1,1,0,1], [0,0,0,1,0,0,0,1,0,0], [0,1,0,0,0,0,1,0,1,1], [0,0,0,0,0,0,0,0,0,1] ); $Z[$_][$_]=1for 0..9; $N=<>; (@Z=mul@Z),$N+1>>$=&1and@Z=mul@@while$=--; print$Z[0][9]