from functools import lru_cache

import sys

sys.setrecursionlimit(10 ** 7)



N = int(eval(input()))

MOD = 10**9 + 7



def isOk(T):

    for i in range(4):

        t = list(T)

        if i >= 1:

            t[i - 1], t[i] = t[i], t[i - 1]

        if 'AGC' in ''.join(t):

            return False

    return True



@lru_cache(maxsize=None)

def search(n, prev):

    if n == 0:

        return 1



    ret = 0

    for s in ['A', 'G', 'C', 'T']:

        t = (prev + s)[1:]

        if isOk(t):

            ret += search(n - 1, t)

            ret %= MOD



    return ret



print((search(N, 'ZZZZ')))
from functools import lru_cache

import sys

sys.setrecursionlimit(10**7)



N = int(eval(input()))

MOD = 10**9 + 7

S = ['A', 'G', 'C', 'T']

M = set(['AGC', 'GAC', 'ACG'])



for s in S:

    M.add(s + 'AGC')

    M.add(s + 'GAC')

    M.add(s + 'ACG')

    M.add('A' + s + 'GC')

    M.add('AG' + s + 'C')



@lru_cache(maxsize=None)

def search(prev, length):

    if length >= N:

        return 1



    ret = 0



    for s in S:

        T = prev + s

        if not T in M:

            T = T[:: -1][: 3][:: -1]

            ret += search(T, length + 1)

    return ret % MOD



ans = search('', 0)

print(ans)

from functools import lru_cache
import sys

sys.setrecursionlimit(10**7)
N = int(eval(input()))
MOD = 10**9 + 7


def isOk(T):
    for i in range(4):
        t = list(T)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if "AGC" in "".join(t):
            return False
    return True


@lru_cache(maxsize=None)
def search(n, prev):
    if n == 0:
        return 1
    ret = 0
    for s in ["A", "G", "C", "T"]:
        t = (prev + s)[1:]
        if isOk(t):
            ret += search(n - 1, t)
            ret %= MOD
    return ret


print((search(N, "ZZZZ")))

from functools import lru_cache
import sys

sys.setrecursionlimit(10**7)
N = int(eval(input()))
MOD = 10**9 + 7
S = ["A", "G", "C", "T"]
M = set(["AGC", "GAC", "ACG"])
for s in S:
    M.add(s + "AGC")
    M.add(s + "GAC")
    M.add(s + "ACG")
    M.add("A" + s + "GC")
    M.add("AG" + s + "C")


@lru_cache(maxsize=None)
def search(prev, length):
    if length >= N:
        return 1
    ret = 0
    for s in S:
        T = prev + s
        if not T in M:
            T = T[::-1][:3][::-1]
            ret += search(T, length + 1)
    return ret % MOD


ans = search("", 0)
print(ans)

- - -def isOk(T): -    for i in range(4): -        t = list(T) -        if i >= 1: -            t[i - 1], t[i] = t[i], t[i - 1] -        if "AGC" in "".join(t): -            return False -    return True +S = ["A", "G", "C", "T"] +M = set(["AGC", "GAC", "ACG"]) +for s in S: +    M.add(s + "AGC") +    M.add(s + "GAC") +    M.add(s + "ACG") +    M.add("A" + s + "GC") +    M.add("AG" + s + "C") -def search(n, prev): -    if n == 0: +def search(prev, length): +    if length >= N: -    for s in ["A", "G", "C", "T"]: -        t = (prev + s)[1:] -        if isOk(t): -            ret += search(n - 1, t) -            ret %= MOD -    return ret +    for s in S: +        T = prev + s +        if not T in M: +            T = T[::-1][:3][::-1] +            ret += search(T, length + 1) +    return ret % MOD -print((search(N, "ZZZZ"))) +ans = search("", 0) +print(ans)