Scanf.scanf "%d" (fun n ->
    let module M = Map.Make (struct type t = string let compare = compare end) in
    let atgc k = "ACGT".[k] in
    let rec loopi i map =
        if i = 64 then map else
            let key = Printf.sprintf "%c%c%c" (atgc (i mod 4)) (atgc (i / 16)) (atgc ((i / 4) mod 4)) in
            let map = if key = "AGC" || key = "ACG" || key = "GAC" then map else M.add key 1 map in
            loopi (i + 1) map
    in
    let check k t =
        let nk = k ^ t in
        let ch s p a =
            let ss = String.init 4 (fun i ->
                if i = p then s.[i + 1] else
                if i = p + 1 then s.[i - 1] else s.[i]) 
            in
            String.sub ss a 3
        in
        ch nk 0 1 <> "AGC" && ch nk 1 1 <> "AGC" && ch nk 2 1 <> "AGC" && ch nk 4 1 <> "AGC" && ch nk 2 0 <> "AGC"
    in
    let (+@) a b = (a + b) mod 1_000_000_007 in
    let add k t v map =
        let nk = String.sub (k ^ t) 1 3 in
        M.add nk (v +@ try M.find nk map with _ -> 0) map
    in
    let rec loop i map =
        if i = n then map else
            let newmap = M.fold (fun k v newmap ->
                List.fold_left (fun acc t ->
                    if check k t then add k t v acc else acc) newmap [ "A"; "C"; "G"; "T" ]
            ) map M.empty
            in
            loop (i + 1) newmap
    in
    let map = loop 3 (loopi 0 M.empty) in
    M.fold (fun _ v acc -> acc +@ v) map 0 |> Printf.printf "%d\n"
)