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')))
#貰うDP

import itertools

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

memo = [{'AGC':0, 'ACG':0, 'GAC':0} for i in range(N + 1)]

C = list('ACGT')

for c in itertools.product(C, C, C):

    c = ''.join(c)

    if c in memo[3]:

        continue

    else:

        memo[3][c] = 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]

    ret = 0

    for c in 'ACGT':

        if ok(c + last3):

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

    memo[cur][last3] = ret

    return ret



def answer(n):

    ans = 0

    clist = list('ACGT')

    for c in itertools.product(clist, clist, clist):

        ch = ''.join(c)

        ans += dfs(n, ch)

    return ans % MOD



print((answer(N)))
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")))

# 貰うDP
import itertools

N, MOD = int(eval(input())), 10**9 + 7
memo = [{"AGC": 0, "ACG": 0, "GAC": 0} for i in range(N + 1)]
C = list("ACGT")
for c in itertools.product(C, C, C):
    c = "".join(c)
    if c in memo[3]:
        continue
    else:
        memo[3][c] = 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]
    ret = 0
    for c in "ACGT":
        if ok(c + last3):
            ret = (ret + dfs(cur - 1, c + last3[:-1])) % MOD
    memo[cur][last3] = ret
    return ret


def answer(n):
    ans = 0
    clist = list("ACGT")
    for c in itertools.product(clist, clist, clist):
        ch = "".join(c)
        ans += dfs(n, ch)
    return ans % MOD


print((answer(N)))

+# 貰うDP +import itertools + -memo = [{} for i in range(N + 1)] +memo = [{"AGC": 0, "ACG": 0, "GAC": 0} for i in range(N + 1)] +C = list("ACGT") +for c in itertools.product(C, C, C): +    c = "".join(c) +    if c in memo[3]: +        continue +    else: +        memo[3][c] = 1 -        if "".join(t).count("AGC") >= 1: -            return False +            if "".join(t).count("AGC") == 1: +                return False -    # メモ化 -    # 最後までたどり着いた数列 -    if cur == N: -        return 1 -    # 漸化式計算 -        if ok(last3 + c): -            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD +        if ok(c + last3): +            ret = (ret + dfs(cur - 1, c + last3[:-1])) % MOD -print((dfs(0, "TTT"))) +def answer(n): +    ans = 0 +    clist = list("ACGT") +    for c in itertools.product(clist, clist, clist): +        ch = "".join(c) +        ans += dfs(n, ch) +    return ans % MOD + + +print((answer(N)))