import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  print . go n $ States 1 0 0 0 0 0 0 0 0 0

data States = States !Int !Int !Int !Int !Int !Int !Int !Int !Int !Int

go :: Int -> States -> Int
go 0 (States s0 a ac ag agg agt at atg g ga) = modSum [s0, a, ac, ag, agg, agt, at, atg, g, ga]
go l (States s0 a ac ag agg agt at atg g ga) = go (pred l) (States s0' a' ac' ag' agg' agt' at' atg' g' ga')
  where
    s0' = modSum [s0 * 2, ac * 2, agg, agt, at * 2, atg, g * 2]
    a' = modSum [s0, a, ac, agt, at, ga]
    ac' = a
    ag' = modSum [a, ga]
    agg' = ag
    agt' = ag
    at' = modSum [a, ga]
    atg' = at
    g' = modSum [s0, agg, agt, atg, g]
    ga' = modSum [ag, agg, atg, g]
    -- o' = modSum [ac, ag, agg, agt, atg, ga, o * 4]
{-# INLINE go #-}

modSum :: [Int] -> Int
modSum = foldl modAdd 0
  where
    modAdd :: Int -> Int -> Int
    modAdd x y = (x + y) `mod` modulus
{-# INLINE modSum #-}

modulus = 10 ^ 9 + 7 :: Int
{-# INLINE modulus #-}

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
