N = int(eval(input()))

MOD = 10 ** 9 + 7

C = 'ACGT'



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



def ok(l4):

  if (l4[0:3] in ['AGC', 'GAC', 'ACG'] or

      l4[1:4] in ['AGC', 'GAC', 'ACG'] or

      l4[0:1] + l4[2:4] == 'AGC' or

      l4[0:2] + l4[3:4] == 'AGC'):

    return False

  else:

    return True



for c1 in C:

  for c2 in C:

    for c3 in C:

      l4 = 'X' + c1 + c2 + c3

      if ok(l4):

        dp[3][l4] = 1

      else:

        dp[3][l4] = 0



for i in range(4, N+1):

  for l4 in list(dp[i-1].keys()):

    for c in C:

      next_l4 = l4[1:4] + c

      if next_l4 not in dp[i]:

        dp[i][next_l4] = 0

      if ok(next_l4):

        dp[i][next_l4] = (dp[i][next_l4] + dp[i-1][l4]) % MOD



ans = 0

for count in list(dp[N].values()):

  ans = (ans + count) % MOD

print(ans)
import sys

N = int(eval(input()))

MOD = 10**9+7

ACGT = ['A', 'C', 'G', 'T']

# ?AGC

# ?GAC

# ?ACG

# A?GC

# AG?C



def ok(l4):

  l3 = l4[1:4]

  if l3 == 'AGC' or l3 =='GAC' or l3 == 'ACG':

    return False

  if l4[0] == 'A' and l4[2:4] == 'GC':

    return False

  if l4[0:2] == 'AG' and l4[3] == 'C':

    return False

  return True



# dp[i][l4] = i文字かつ末尾4文字がlast4な数

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



for c1 in ACGT:

  for c2 in ACGT:

    for c3 in ACGT:

      l4 = 'X' + c1 + c2 + c3

      if ok(l4):

        dp[3][l4] = 1

      else:

        dp[3][l4] = 0



for i in range(4, N+1):

  for l4 in list(dp[i-1].keys()):

    for c in ACGT:

      next_l4 = l4[1:4] + c

      if not next_l4 in dp[i]:

        dp[i][next_l4] = 0

      if ok(next_l4):

        dp[i][next_l4] += dp[i-1][l4]



print((sum(dp[N].values())%MOD))
N = int(eval(input()))
MOD = 10**9 + 7
C = "ACGT"
dp = [{} for _ in range(N + 1)]


def ok(l4):
    if (
        l4[0:3] in ["AGC", "GAC", "ACG"]
        or l4[1:4] in ["AGC", "GAC", "ACG"]
        or l4[0:1] + l4[2:4] == "AGC"
        or l4[0:2] + l4[3:4] == "AGC"
    ):
        return False
    else:
        return True


for c1 in C:
    for c2 in C:
        for c3 in C:
            l4 = "X" + c1 + c2 + c3
            if ok(l4):
                dp[3][l4] = 1
            else:
                dp[3][l4] = 0
for i in range(4, N + 1):
    for l4 in list(dp[i - 1].keys()):
        for c in C:
            next_l4 = l4[1:4] + c
            if next_l4 not in dp[i]:
                dp[i][next_l4] = 0
            if ok(next_l4):
                dp[i][next_l4] = (dp[i][next_l4] + dp[i - 1][l4]) % MOD
ans = 0
for count in list(dp[N].values()):
    ans = (ans + count) % MOD
print(ans)

import sys

N = int(eval(input()))
MOD = 10**9 + 7
ACGT = ["A", "C", "G", "T"]
# ?AGC
# ?GAC
# ?ACG
# A?GC
# AG?C
def ok(l4):
    l3 = l4[1:4]
    if l3 == "AGC" or l3 == "GAC" or l3 == "ACG":
        return False
    if l4[0] == "A" and l4[2:4] == "GC":
        return False
    if l4[0:2] == "AG" and l4[3] == "C":
        return False
    return True


# dp[i][l4] = i文字かつ末尾4文字がlast4な数
dp = [{} for _ in range(N + 1)]
for c1 in ACGT:
    for c2 in ACGT:
        for c3 in ACGT:
            l4 = "X" + c1 + c2 + c3
            if ok(l4):
                dp[3][l4] = 1
            else:
                dp[3][l4] = 0
for i in range(4, N + 1):
    for l4 in list(dp[i - 1].keys()):
        for c in ACGT:
            next_l4 = l4[1:4] + c
            if not next_l4 in dp[i]:
                dp[i][next_l4] = 0
            if ok(next_l4):
                dp[i][next_l4] += dp[i - 1][l4]
print((sum(dp[N].values()) % MOD))

+import sys + -C = "ACGT" -dp = [{} for _ in range(N + 1)] +ACGT = ["A", "C", "G", "T"] +# ?AGC +# ?GAC +# ?ACG +# A?GC +# AG?C +def ok(l4): +    l3 = l4[1:4] +    if l3 == "AGC" or l3 == "GAC" or l3 == "ACG": +        return False +    if l4[0] == "A" and l4[2:4] == "GC": +        return False +    if l4[0:2] == "AG" and l4[3] == "C": +        return False +    return True -def ok(l4): -    if ( -        l4[0:3] in ["AGC", "GAC", "ACG"] -        or l4[1:4] in ["AGC", "GAC", "ACG"] -        or l4[0:1] + l4[2:4] == "AGC" -        or l4[0:2] + l4[3:4] == "AGC" -    ): -        return False -    else: -        return True - - -for c1 in C: -    for c2 in C: -        for c3 in C: +# dp[i][l4] = i文字かつ末尾4文字がlast4な数 +dp = [{} for _ in range(N + 1)] +for c1 in ACGT: +    for c2 in ACGT: +        for c3 in ACGT: -        for c in C: +        for c in ACGT: -            if next_l4 not in dp[i]: +            if not next_l4 in dp[i]: -                dp[i][next_l4] = (dp[i][next_l4] + dp[i - 1][l4]) % MOD -ans = 0 -for count in list(dp[N].values()): -    ans = (ans + count) % MOD -print(ans) +                dp[i][next_l4] += dp[i - 1][l4] +print((sum(dp[N].values()) % MOD))