N = int(eval(input()))

MOD = 10**9 + 7



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



def isAGC(char4):

    for i in range(4):

        tmp = list(char4)

        if i != 3:

            tmp[i], tmp[i + 1] = tmp[i + 1], tmp[i]

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

            return True

    return False



def dfs(cur, char3):

    if char3 in memo[cur]:

        return memo[cur][char3]

    if cur == N:

        return 1

    

    ret = 0

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

        if not isAGC(char3 + c):

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



    memo[cur][char3] = ret

    return ret



print((dfs(0, 'XXX')))
N = int(eval(input()))

MOD = 10**9 + 7



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

for i in range(4):

    for j in range(4):

        for k in range(4):

            dp[0][i][j][k] = 0

            dp[1][i][j][k] = 1

            dp[2][i][j][k] = 1

            if i == 2 and j == 1 and k == 0:

                continue

            elif i == 1 and j == 2 and k == 0:

                continue

            elif i == 2 and j == 0 and k == 1:

                continue

            dp[3][i][j][k] = 1





for n in range(3, N):

    for i in range(4):

        for j in range(4):

            for k in range(4):

                for c in range(4):

                    if c == 1 and i == 2 and j == 0:

                        continue

                    elif c == 2 and i == 1 and j == 0:

                        continue

                    elif c == 2 and i == 0 and j == 1:

                        continue

                    elif c == 2 and i == 1 and k == 0:

                        continue

                    elif c == 2 and j == 1 and k == 0:

                        continue

                    dp[n + 1][c][i][j] += dp[n][i][j][k]

                    dp[n + 1][c][i][j] %= MOD



ans = 0

for i in range(4):

    for j in range(4):

        for k in range(4):

            ans += dp[N][i][j][k]

print((ans % MOD))

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


def isAGC(char4):
    for i in range(4):
        tmp = list(char4)
        if i != 3:
            tmp[i], tmp[i + 1] = tmp[i + 1], tmp[i]
        if "".join(tmp).count("AGC") >= 1:
            return True
    return False


def dfs(cur, char3):
    if char3 in memo[cur]:
        return memo[cur][char3]
    if cur == N:
        return 1
    ret = 0
    for c in ["A", "C", "G", "T"]:
        if not isAGC(char3 + c):
            ret = (ret + dfs(cur + 1, char3[1:] + c)) % MOD
    memo[cur][char3] = ret
    return ret


print((dfs(0, "XXX")))

N = int(eval(input()))
MOD = 10**9 + 7
dp = [[[[0] * 4 for ___ in range(4)] for __ in range(4)] for _ in range(N + 1)]
for i in range(4):
    for j in range(4):
        for k in range(4):
            dp[0][i][j][k] = 0
            dp[1][i][j][k] = 1
            dp[2][i][j][k] = 1
            if i == 2 and j == 1 and k == 0:
                continue
            elif i == 1 and j == 2 and k == 0:
                continue
            elif i == 2 and j == 0 and k == 1:
                continue
            dp[3][i][j][k] = 1
for n in range(3, N):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for c in range(4):
                    if c == 1 and i == 2 and j == 0:
                        continue
                    elif c == 2 and i == 1 and j == 0:
                        continue
                    elif c == 2 and i == 0 and j == 1:
                        continue
                    elif c == 2 and i == 1 and k == 0:
                        continue
                    elif c == 2 and j == 1 and k == 0:
                        continue
                    dp[n + 1][c][i][j] += dp[n][i][j][k]
                    dp[n + 1][c][i][j] %= MOD
ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[N][i][j][k]
print((ans % MOD))

-memo = [{} for _ in range(N + 1)] - - -def isAGC(char4): +dp = [[[[0] * 4 for ___ in range(4)] for __ in range(4)] for _ in range(N + 1)] +for i in range(4): +    for j in range(4): +        for k in range(4): +            dp[0][i][j][k] = 0 +            dp[1][i][j][k] = 1 +            dp[2][i][j][k] = 1 +            if i == 2 and j == 1 and k == 0: +                continue +            elif i == 1 and j == 2 and k == 0: +                continue +            elif i == 2 and j == 0 and k == 1: +                continue +            dp[3][i][j][k] = 1 +for n in range(3, N): -        tmp = list(char4) -        if i != 3: -            tmp[i], tmp[i + 1] = tmp[i + 1], tmp[i] -        if "".join(tmp).count("AGC") >= 1: -            return True -    return False - - -def dfs(cur, char3): -    if char3 in memo[cur]: -        return memo[cur][char3] -    if cur == N: -        return 1 -    ret = 0 -    for c in ["A", "C", "G", "T"]: -        if not isAGC(char3 + c): -            ret = (ret + dfs(cur + 1, char3[1:] + c)) % MOD -    memo[cur][char3] = ret -    return ret - - -print((dfs(0, "XXX"))) +        for j in range(4): +            for k in range(4): +                for c in range(4): +                    if c == 1 and i == 2 and j == 0: +                        continue +                    elif c == 2 and i == 1 and j == 0: +                        continue +                    elif c == 2 and i == 0 and j == 1: +                        continue +                    elif c == 2 and i == 1 and k == 0: +                        continue +                    elif c == 2 and j == 1 and k == 0: +                        continue +                    dp[n + 1][c][i][j] += dp[n][i][j][k] +                    dp[n + 1][c][i][j] %= MOD +ans = 0 +for i in range(4): +    for j in range(4): +        for k in range(4): +            ans += dp[N][i][j][k] +print((ans % MOD))