sub mul{ my@C; for$y(0..9){ for$x(0..9){ for(0..9){ ($C[$y][$x]+=$Z[$y][$_]*$_[$_][$x])%=1e9+7 } } } @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]