"""

1.4種類の文字ATGC

2.AGCを作ってはならない

3.隣り合う文字を1箇所だけ入れ替えても、AGCになってはならない



3. が厄介

変えないAGC 

0-1 A*GC

1-2 GAC

2-3 ACG

3-4 AG*C



とりあえず3文字分テーブルに持たせながらdp？

"""



mod = 10**9 + 7

N = int(eval(input()))

dp =[[[[0]*5 for i in range(5)] for j in range(5)] for n in range(108)]



nul = 0

A = 1

G = 2

C = 3

T = 4



"""

AGC

0-1 A*GC

1-2 GAC

2-3 ACG

3-4 AG*C

"""

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

for n in range(N):

    for n3 in range(5):             # 3つ前

        for n2 in range(5):         # 2つ前

            for n1 in range(5):     # 1つ前

                for s in range(1,5):  # 今

                    if n2 == A and n1 == G and s == C: continue

                    if n3 == A and n1 == G and s == C: continue

                    if n2 == G and n1 == A and s == C: continue

                    if n2 == A and n1 == C and s == G: continue

                    if n3 == A and n2 == G and s == C: continue

                    # print(n,n1,n2,n3,s)

                    dp[n+1][n2][n1][s] += dp[n][n3][n2][n1]                    

ans = 0

for i in range(5):

    for j in range(5):

        for k in range(5):

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

print((ans%mod))
n = int(eval(input()))

MOD = 10**9+7

d = {"A":0, "C":1, "G":2, "T":3}

dic = {}

dic_r = {}

for i0 in "ACGT":

    for i1 in "ACGT":

        for i2 in "ACGT":

            v = 4**2*d[i2] + 4*d[i1] + d[i0]

            k = i2+i1+i0

            dic[k] = v

            dic_r[v] = k



dp = [[0] * 64 for i in range(n)]

for i in range(64):

    dp[0][i] = 1

dp[0][dic["AGC"]] = 0

dp[0][dic["ACG"]] = 0

dp[0][dic["GAC"]] = 0

for i in range(n-3):

    for j in range(64):

        v = dic_r[j]

        for s in "ACGT":

            # AG*C

            if v[0] == "A" and v[1] == "G":

                if s != "C":

                    new = v[1]+v[2]+s

                    dp[i+1][dic[new]] += dp[i][dic[v]]

            # A*GC

            elif v[0] == "A" and v[2] == "G":

                if s != "C":

                    new = v[1]+v[2]+s

                    dp[i+1][dic[new]] += dp[i][dic[v]]

            # *GAC

            elif v[1] == "G" and v[2] == "A":

                if s != "C":

                    new = v[1]+v[2]+s

                    dp[i+1][dic[new]] += dp[i][dic[v]]

            # *ACG

            elif v[1] == "A" and v[2] == "C":

                if s != "G":

                    new = v[1]+v[2]+s

                    dp[i+1][dic[new]] += dp[i][dic[v]]

            # *AGC

            elif v[1] == "A" and v[2] == "G":

                if s != "C":

                    new = v[1]+v[2]+s

                    dp[i+1][dic[new]] += dp[i][dic[v]]

            else:

                new = v[1] + v[2] + s

                dp[i+1][dic[new]] += dp[i][dic[v]]

    continue

print((sum(dp[n-3])%MOD))





"""
1.4種類の文字ATGC
2.AGCを作ってはならない
3.隣り合う文字を1箇所だけ入れ替えても、AGCになってはならない
3. が厄介
変えないAGC 
0-1 A*GC
1-2 GAC
2-3 ACG
3-4 AG*C
とりあえず3文字分テーブルに持たせながらdp？
"""
mod = 10**9 + 7
N = int(eval(input()))
dp = [[[[0] * 5 for i in range(5)] for j in range(5)] for n in range(108)]
nul = 0
A = 1
G = 2
C = 3
T = 4
"""
AGC
0-1 A*GC
1-2 GAC
2-3 ACG
3-4 AG*C
"""
dp[0][0][0][0] = 1
for n in range(N):
    for n3 in range(5):  # 3つ前
        for n2 in range(5):  # 2つ前
            for n1 in range(5):  # 1つ前
                for s in range(1, 5):  # 今
                    if n2 == A and n1 == G and s == C:
                        continue
                    if n3 == A and n1 == G and s == C:
                        continue
                    if n2 == G and n1 == A and s == C:
                        continue
                    if n2 == A and n1 == C and s == G:
                        continue
                    if n3 == A and n2 == G and s == C:
                        continue
                    # print(n,n1,n2,n3,s)
                    dp[n + 1][n2][n1][s] += dp[n][n3][n2][n1]
ans = 0
for i in range(5):
    for j in range(5):
        for k in range(5):
            ans += dp[N][i][j][k]
print((ans % mod))

n = int(eval(input()))
MOD = 10**9 + 7
d = {"A": 0, "C": 1, "G": 2, "T": 3}
dic = {}
dic_r = {}
for i0 in "ACGT":
    for i1 in "ACGT":
        for i2 in "ACGT":
            v = 4**2 * d[i2] + 4 * d[i1] + d[i0]
            k = i2 + i1 + i0
            dic[k] = v
            dic_r[v] = k
dp = [[0] * 64 for i in range(n)]
for i in range(64):
    dp[0][i] = 1
dp[0][dic["AGC"]] = 0
dp[0][dic["ACG"]] = 0
dp[0][dic["GAC"]] = 0
for i in range(n - 3):
    for j in range(64):
        v = dic_r[j]
        for s in "ACGT":
            # AG*C
            if v[0] == "A" and v[1] == "G":
                if s != "C":
                    new = v[1] + v[2] + s
                    dp[i + 1][dic[new]] += dp[i][dic[v]]
            # A*GC
            elif v[0] == "A" and v[2] == "G":
                if s != "C":
                    new = v[1] + v[2] + s
                    dp[i + 1][dic[new]] += dp[i][dic[v]]
            # *GAC
            elif v[1] == "G" and v[2] == "A":
                if s != "C":
                    new = v[1] + v[2] + s
                    dp[i + 1][dic[new]] += dp[i][dic[v]]
            # *ACG
            elif v[1] == "A" and v[2] == "C":
                if s != "G":
                    new = v[1] + v[2] + s
                    dp[i + 1][dic[new]] += dp[i][dic[v]]
            # *AGC
            elif v[1] == "A" and v[2] == "G":
                if s != "C":
                    new = v[1] + v[2] + s
                    dp[i + 1][dic[new]] += dp[i][dic[v]]
            else:
                new = v[1] + v[2] + s
                dp[i + 1][dic[new]] += dp[i][dic[v]]
    continue
print((sum(dp[n - 3]) % MOD))

-""" -1.4種類の文字ATGC -2.AGCを作ってはならない -3.隣り合う文字を1箇所だけ入れ替えても、AGCになってはならない -3. が厄介 -変えないAGC -0-1 A*GC -1-2 GAC -2-3 ACG -3-4 AG*C -とりあえず3文字分テーブルに持たせながらdp？ -""" -mod = 10**9 + 7 -N = int(eval(input())) -dp = [[[[0] * 5 for i in range(5)] for j in range(5)] for n in range(108)] -nul = 0 -A = 1 -G = 2 -C = 3 -T = 4 -""" -AGC -0-1 A*GC -1-2 GAC -2-3 ACG -3-4 AG*C -""" -dp[0][0][0][0] = 1 -for n in range(N): -    for n3 in range(5):  # 3つ前 -        for n2 in range(5):  # 2つ前 -            for n1 in range(5):  # 1つ前 -                for s in range(1, 5):  # 今 -                    if n2 == A and n1 == G and s == C: -                        continue -                    if n3 == A and n1 == G and s == C: -                        continue -                    if n2 == G and n1 == A and s == C: -                        continue -                    if n2 == A and n1 == C and s == G: -                        continue -                    if n3 == A and n2 == G and s == C: -                        continue -                    # print(n,n1,n2,n3,s) -                    dp[n + 1][n2][n1][s] += dp[n][n3][n2][n1] -ans = 0 -for i in range(5): -    for j in range(5): -        for k in range(5): -            ans += dp[N][i][j][k] -print((ans % mod)) +n = int(eval(input())) +MOD = 10**9 + 7 +d = {"A": 0, "C": 1, "G": 2, "T": 3} +dic = {} +dic_r = {} +for i0 in "ACGT": +    for i1 in "ACGT": +        for i2 in "ACGT": +            v = 4**2 * d[i2] + 4 * d[i1] + d[i0] +            k = i2 + i1 + i0 +            dic[k] = v +            dic_r[v] = k +dp = [[0] * 64 for i in range(n)] +for i in range(64): +    dp[0][i] = 1 +dp[0][dic["AGC"]] = 0 +dp[0][dic["ACG"]] = 0 +dp[0][dic["GAC"]] = 0 +for i in range(n - 3): +    for j in range(64): +        v = dic_r[j] +        for s in "ACGT": +            # AG*C +            if v[0] == "A" and v[1] == "G": +                if s != "C": +                    new = v[1] + v[2] + s +                    dp[i + 1][dic[new]] += dp[i][dic[v]] +            # A*GC +            elif v[0] == "A" and v[2] == "G": +                if s != "C": +                    new = v[1] + v[2] + s +                    dp[i + 1][dic[new]] += dp[i][dic[v]] +            # *GAC +            elif v[1] == "G" and v[2] == "A": +                if s != "C": +                    new = v[1] + v[2] + s +                    dp[i + 1][dic[new]] += dp[i][dic[v]] +            # *ACG +            elif v[1] == "A" and v[2] == "C": +                if s != "G": +                    new = v[1] + v[2] + s +                    dp[i + 1][dic[new]] += dp[i][dic[v]] +            # *AGC +            elif v[1] == "A" and v[2] == "G": +                if s != "C": +                    new = v[1] + v[2] + s +                    dp[i + 1][dic[new]] += dp[i][dic[v]] +            else: +                new = v[1] + v[2] + s +                dp[i + 1][dic[new]] += dp[i][dic[v]] +    continue +print((sum(dp[n - 3]) % MOD))