N, MOD = int(eval(input())), 10 ** 9 + 7

memo = [{} for i in range(N + 1)]





def ok(last4):

    for i in range(4):

        t = list(last4)

        if i >= 1:

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

        if ''.join(t).count('AGC') >= 1:

            return False

    return True





def dfs(cur, last3):

    if last3 in memo[cur]:

        return memo[cur][last3]

    if cur == N:

        return 1

    ret = 0

    for c in 'ACGT':

        if ok(last3 + c):

            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD

    memo[cur][last3] = ret

    return ret





print((dfs(0, 'TTT')))

N = int(eval(input()))





def is_valid(last_4):

    cand = [last_4]

    for i in range(3):

        cand.append(last_4[:i] + last_4[i + 1] + last_4[i] + last_4[i + 2:])



    for m in cand:

        if "AGC" in m:

            return False

    return True





memo = [{} for i in range(N + 1)]

mod = 10**9 + 7





def dfs(index, last_3):

    if last_3 in list(memo[index].keys()):

        return memo[index][last_3]

    elif index == N:

        return 1

    else:

        s = 0

        for c in "AGCT":

            if is_valid(last_3 + c):

                s = (s + dfs(index + 1, last_3[1:] + c)) % mod

        memo[index][last_3] = s

        return s





print((dfs(0, "HHH")))

N, MOD = int(eval(input())), 10**9 + 7
memo = [{} for i in range(N + 1)]


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


def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in "ACGT":
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret


print((dfs(0, "TTT")))

N = int(eval(input()))


def is_valid(last_4):
    cand = [last_4]
    for i in range(3):
        cand.append(last_4[:i] + last_4[i + 1] + last_4[i] + last_4[i + 2 :])
    for m in cand:
        if "AGC" in m:
            return False
    return True


memo = [{} for i in range(N + 1)]
mod = 10**9 + 7


def dfs(index, last_3):
    if last_3 in list(memo[index].keys()):
        return memo[index][last_3]
    elif index == N:
        return 1
    else:
        s = 0
        for c in "AGCT":
            if is_valid(last_3 + c):
                s = (s + dfs(index + 1, last_3[1:] + c)) % mod
        memo[index][last_3] = s
        return s


print((dfs(0, "HHH")))

-N, MOD = int(eval(input())), 10**9 + 7 -memo = [{} for i in range(N + 1)] +N = int(eval(input())) -def ok(last4): -    for i in range(4): -        t = list(last4) -        if i >= 1: -            t[i - 1], t[i] = t[i], t[i - 1] -        if "".join(t).count("AGC") >= 1: +def is_valid(last_4): +    cand = [last_4] +    for i in range(3): +        cand.append(last_4[:i] + last_4[i + 1] + last_4[i] + last_4[i + 2 :]) +    for m in cand: +        if "AGC" in m: -def dfs(cur, last3): -    if last3 in memo[cur]: -        return memo[cur][last3] -    if cur == N: -        return 1 -    ret = 0 -    for c in "ACGT": -        if ok(last3 + c): -            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD -    memo[cur][last3] = ret -    return ret +memo = [{} for i in range(N + 1)] +mod = 10**9 + 7 -print((dfs(0, "TTT"))) +def dfs(index, last_3): +    if last_3 in list(memo[index].keys()): +        return memo[index][last_3] +    elif index == N: +        return 1 +    else: +        s = 0 +        for c in "AGCT": +            if is_valid(last_3 + c): +                s = (s + dfs(index + 1, last_3[1:] + c)) % mod +        memo[index][last_3] = s +        return s + + +print((dfs(0, "HHH")))