import Data.Map ((!))
import qualified Data.Map as M
import Control.Monad

main = readLn >>= print.solve

solve :: Int -> Int
solve = M.foldr (+%) 0.(ans!!)
  where
  ans = M.empty : M.empty : M.empty
        : (M.fromList.(`zip`repeat 1).filter correct.replicateM 3) "AGCT"
        : map f (drop 3 ans)
  f pMap = foldr g M.empty correctStrs4
    where g head4 = M.insertWith (+%) (init head4) (pMap!tail head4)
  correctStrs4 = filter correct $ replicateM 4 "ACGT"
  correct ('A':'G':'C': _ ) = False
  correct [ _ ,'A','G','C'] = False
  correct ('A':'C':'G': _ ) = False
  correct [ _ ,'A','C','G'] = False
  correct ('G':'A':'C': _ ) = False
  correct [ _ ,'G','A','C'] = False
  correct ['A', _ ,'G','C'] = False
  correct ['A','G', _ ,'C'] = False
  correct _ = True

infixl 6 +%
a +% b = (a+b)`mod`1000000007