n=int(eval(input()))

A,C,G,T,M,R=0,1,2,3,10**9+7,list(range(4))

dp=[[[[0]*4for k in R]for j in R]for i in range(n+1)]

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

for i in range(1,n+1):

  for j in R:

    for k in R:

      for l in R:

        for m in R:

          if(G,A,C)!=(k,l,m)!=(A,C,G)!=(k,l,m)!=(A,G,C)!=(j,l,m)!=(A,G,C)!=(j,k,m):dp[i][k][l][m]=(dp[i][k][l][m]+dp[i-1][j][k][l])%M

print((sum(c for a in dp[n]for b in a for c in b)%M))
n=int(eval(input()))

M,R=10**9+7,list(range(4))

dp=[[[[0]*4for k in R]for j in R]for i in range(n+1)]

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

for i in range(1,n+1):

  for j in R:

    for k in R:

      for l in R:

        for m in R:

          if(2,0,1)!=(k,l,m)!=(0,1,2)!=(k,l,m)!=(0,2,1)!=(j,l,m)!=(0,2,1)!=(j,k,m):dp[i][k][l][m]=(dp[i][k][l][m]+dp[i-1][j][k][l])%M

print((sum(c for a in dp[n]for b in a for c in b)%M))
n = int(eval(input()))
A, C, G, T, M, R = 0, 1, 2, 3, 10**9 + 7, list(range(4))
dp = [[[[0] * 4 for k in R] for j in R] for i in range(n + 1)]
dp[0][T][T][T] = 1
for i in range(1, n + 1):
    for j in R:
        for k in R:
            for l in R:
                for m in R:
                    if (
                        (G, A, C)
                        != (k, l, m)
                        != (A, C, G)
                        != (k, l, m)
                        != (A, G, C)
                        != (j, l, m)
                        != (A, G, C)
                        != (j, k, m)
                    ):
                        dp[i][k][l][m] = (dp[i][k][l][m] + dp[i - 1][j][k][l]) % M
print((sum(c for a in dp[n] for b in a for c in b) % M))

n = int(eval(input()))
M, R = 10**9 + 7, list(range(4))
dp = [[[[0] * 4 for k in R] for j in R] for i in range(n + 1)]
dp[0][3][3][3] = 1
for i in range(1, n + 1):
    for j in R:
        for k in R:
            for l in R:
                for m in R:
                    if (
                        (2, 0, 1)
                        != (k, l, m)
                        != (0, 1, 2)
                        != (k, l, m)
                        != (0, 2, 1)
                        != (j, l, m)
                        != (0, 2, 1)
                        != (j, k, m)
                    ):
                        dp[i][k][l][m] = (dp[i][k][l][m] + dp[i - 1][j][k][l]) % M
print((sum(c for a in dp[n] for b in a for c in b) % M))

-A, C, G, T, M, R = 0, 1, 2, 3, 10**9 + 7, list(range(4)) +M, R = 10**9 + 7, list(range(4)) -dp[0][T][T][T] = 1 +dp[0][3][3][3] = 1 -                        (G, A, C) +                        (2, 0, 1) -                        != (A, C, G) +                        != (0, 1, 2) -                        != (A, G, C) +                        != (0, 2, 1) -                        != (A, G, C) +                        != (0, 2, 1)