N = int(eval(input()))

mod = 10 ** 9 + 7

dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]





def ng(a: int, b: int, c: int):

    return (a == 1 and b == 2 and c == 3)





# 初期状態の直近3文字はTTTであると見なして良い

dp[0][0][0][0] = 1

for i in range(N):

    for a in range(4):

        for b in range(4):

            for c in range(4):

                for d in range(4):

                    # 3文字パターン

                    if (ng(b, c, d) or ng(c, b, d) or ng(b, d, c)):

                        continue

                    # 4文字パターン

                    if ng(a, c, d) or ng(a, b, d):

                        continue

                    # NGパターンがなければ遷移先に足す

                    dp[i+1][b][c][d] = (dp[i][a][b][c] + dp[i+1][b][c][d]) % mod





ans = 0

for a in range(4):

    for b in range(4):

        for c in range(4):

            ans += dp[N][a][b][c] % mod





print((ans % mod))

N = int(eval(input()))

mod = 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 'ATCG':

        if ok(last3 + c):

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

    memo[cur][last3] = ret

    #print(memo, cur)

    return ret





print((dfs(0, 'TTT')))
N = int(eval(input()))
mod = 10**9 + 7
dp = [
    [[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N + 1)
]


def ng(a: int, b: int, c: int):
    return a == 1 and b == 2 and c == 3


# 初期状態の直近3文字はTTTであると見なして良い
dp[0][0][0][0] = 1
for i in range(N):
    for a in range(4):
        for b in range(4):
            for c in range(4):
                for d in range(4):
                    # 3文字パターン
                    if ng(b, c, d) or ng(c, b, d) or ng(b, d, c):
                        continue
                    # 4文字パターン
                    if ng(a, c, d) or ng(a, b, d):
                        continue
                    # NGパターンがなければ遷移先に足す
                    dp[i + 1][b][c][d] = (dp[i][a][b][c] + dp[i + 1][b][c][d]) % mod
ans = 0
for a in range(4):
    for b in range(4):
        for c in range(4):
            ans += dp[N][a][b][c] % mod
print((ans % mod))

N = int(eval(input()))
mod = 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 "ATCG":
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % mod
    memo[cur][last3] = ret
    # print(memo, cur)
    return ret


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

-dp = [ -    [[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N + 1) -] +memo = [{} for i in range(N + 1)] -def ng(a: int, b: int, c: int): -    return a == 1 and b == 2 and c == 3 +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 -# 初期状態の直近3文字はTTTであると見なして良い -dp[0][0][0][0] = 1 -for i in range(N): -    for a in range(4): -        for b in range(4): -            for c in range(4): -                for d in range(4): -                    # 3文字パターン -                    if ng(b, c, d) or ng(c, b, d) or ng(b, d, c): -                        continue -                    # 4文字パターン -                    if ng(a, c, d) or ng(a, b, d): -                        continue -                    # NGパターンがなければ遷移先に足す -                    dp[i + 1][b][c][d] = (dp[i][a][b][c] + dp[i + 1][b][c][d]) % mod -ans = 0 -for a in range(4): -    for b in range(4): -        for c in range(4): -            ans += dp[N][a][b][c] % mod -print((ans % mod)) +def dfs(cur, last3): +    if last3 in memo[cur]: +        return memo[cur][last3] +    if cur == N: +        return 1 +    ret = 0 +    for c in "ATCG": +        if ok(last3 + c): +            ret = (ret + dfs(cur + 1, last3[1:] + c)) % mod +    memo[cur][last3] = ret +    # print(memo, cur) +    return ret + + +print((dfs(0, "TTT")))