CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
MOD = 10**9 + 7
# dp[i][x][y][z] 0:A 1:C 2:G 3:T
dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(n + 1)]
dp[0][3][3][3] = 1
for i in range(n):
    for x in range(4):
        for y in range(4):
            for z in range(4):
                for w in range(4):
                    if x == 0 and z == 2 and w == 1:
                        continue
                    elif y == 0 and z == 2 and w == 1:
                        continue
                    elif y == 2 and z == 0 and w == 1:
                        continue
                    elif y == 0 and z == 1 and w == 2:
                        continue
                    elif x == 0 and y == 2 and w == 1:
                        continue

                    dp[i+1][y][z][w] += dp[i][x][y][z]
                    dp[i+1][y][z][w] %= MOD

ans = 0
for x in range(4):
    for y in range(4):
        for z in range(4):
            ans += dp[n][x][y][z]
            ans %= MOD

print(ans)


# Optimized solution
n = int(eval(input()))
MOD = 10**9 + 7
# dp[i][x][y][z] 0:A 1:C 2:G 3:T
dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(n + 1)]
dp[0][3][3][3] = 1
for i in range(1, n+1):
    for x in range(4):
        for y in range(4):
            for z in range(4):
                for w in range(4):
                    if x == 0 and z == 2 and w == 1:
                        continue
                    elif y == 0 and z == 2 and w == 1:
                        continue
                    elif y == 2 and z == 0 and w == 1:
                        continue
                    elif y == 0 and z == 1 and w == 2:
                        continue
                    elif x == 0 and y == 2 and w == 1:
                        continue

                    dp[i][y][z][w] += dp[i-1][x][y][z]
                    dp[i][y][z][w] %= MOD

ans = 0
for x in range(4):
    for y in range(4):
        for z in range(4):
            ans += dp[n][x][y][z]
            ans %= MOD

print(ans)
# Original solution
N, MOD = int(eval(input())), 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 'ACGT':
		if ok(last3 + c):
			ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
	memo[cur][last3] = ret
	return ret

print((dfs(0, 'TTT')))

# Optimized solution
N, MOD = int(eval(input())), 10 ** 9 + 7
dp = [[[[0 for k in range(4)] for k in range(4)] for j in range(4)] for i in range(101)]
dp[0][3][3][3] = 1

for length in range(N):
  for i in range(4):
    for j in range(4):
      for k in range(4):
        if dp[length][i][j][k] == 0: continue
        for a in range(4):
          if a == 2 and i == 1 and j == 0: continue
          if a == 2 and i == 0 and j == 1: continue
          if a == 1 and i == 2 and j == 0: continue
          if a == 2 and i == 1 and k == 0: continue
          if a == 2 and j == 1 and k == 0: continue

          dp[length + 1][a][i][j] += dp[length][i][j][k]
          dp[length + 1][a][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]
      ans %= MOD

print(ans)
# Original solution
N, MOD = int(eval(input())), 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 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print((dfs(0, 'TTT')))

# Optimized solution
#貰うDP
import itertools
N, MOD = int(eval(input())), 10**9+7
memo = [{'AGC':0, 'ACG':0, 'GAC':0} for i in range(N + 1)]
C = list('ACGT')
for c in itertools.product(C, C, C):
    c = ''.join(c)
    if c in memo[3]:
        continue
    else:
        memo[3][c] = 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]
    ret = 0
    for c in 'ACGT':
        if ok(c + last3):
            ret = (ret + dfs(cur - 1, c + last3[:-1])) % MOD
    memo[cur][last3] = ret
    return ret

def answer(n):
    ans = 0
    clist = list('ACGT')
    for c in itertools.product(clist, clist, clist):
        ch = ''.join(c)
        ans += dfs(n, ch)
    return ans % MOD

print((answer(N)))
# Original solution
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())

from collections import Counter
from itertools import product

def main():
    N = II()
    dp = Counter()
    dp['TTT'] += 1
    for _ in range(N):
        pre = dp
        dp = Counter()
        for p1, p2, p3, cur in product('ACGT', repeat=4):
            if p2 + p1 + cur in ['AGC', 'GAC', 'ACG']:
                continue
            if p3 + p1 + cur == 'AGC':
                continue
            if p3 + p2 + cur == 'AGC':
                continue
            new = p2 + p1 + cur
            old = p3 + p2 + p1
            dp[new] = (dp[new] + pre[old]) % MOD
    ans = sum(dp.values())

    return ans % MOD

print((main()))

# Optimized solution
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())

from collections import Counter
from itertools import product

def main():
    N = II()
    dp = Counter()
    dp['000'] += 1
    for _ in range(N):
        pre = dp
        dp = Counter()
        for old, n in list(pre.items()):
            for cur in 'AGCT':
                new = old[-2:] + cur
                if new in ['AGC', 'GAC', 'ACG']:
                    continue
                if old[-3] + old[-1] + cur == 'AGC':
                    continue
                if old[:-1] + cur == 'AGC':
                    continue
                dp[new] = (dp[new] + n) % MOD
    ans = sum(dp.values())

    return ans % MOD

print((main()))
# Original solution
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())

from collections import Counter
from itertools import product

def main():
    N = II()
    dp = Counter()
    dp['000'] += 1
    for _ in range(N):
        pre = dp
        dp = Counter()
        for old, n in list(pre.items()):
            for cur in 'AGCT':
                new = old[-2:] + cur
                if new in ['AGC', 'GAC', 'ACG']:
                    continue
                if old[-3] + old[-1] + cur == 'AGC':
                    continue
                if old[:-1] + cur == 'AGC':
                    continue
                dp[new] = (dp[new] + n) % MOD
    ans = sum(dp.values())

    return ans % MOD

print((main()))

# Optimized solution
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())

from collections import Counter
from itertools import product

def main():
    N = II()
    dp = Counter()
    dp['000'] += 1
    for _ in range(N):
        pre = dp
        dp = Counter()
        for (p3, p2, p1), n in list(pre.items()):
            for cur in 'AGCT':
                if p2 + p1 + cur in ['AGC', 'GAC', 'ACG']:
                    continue
                if p3 + p1 + cur == 'AGC':
                    continue
                if p3 + p2 + cur == 'AGC':
                    continue
                new = p2 + p1 + cur
                dp[new] = (dp[new] + n) % MOD
    ans = sum(dp.values())

    return ans % MOD

print((main()))
# Original solution
# -*- coding: utf-8 -*-

import itertools
comb = list(map(''.join, itertools.product("ACGT", repeat=4)))

N = int(eval(input()))

dp = {c: [0, 0] for c in comb}
dp["TTTT"] = [1, 0]

for _ in range(N):
    dp_new = {c: [0, 0] for c in comb}
    for k in dp:
        for b in "ACGT":
            if k[2:4] + b in ("AGC", "ACG", "GAC") or k[1:4] + b in ("ACGC", "AGGC", "ATGC", "AGCC", "AGGC", "AGTC"):
                dp_new[k[1:4] + b][1] += dp[k][0] + dp[k][1]
            else:
                dp_new[k[1:4] + b][0] += dp[k][0]
                dp_new[k[1:4] + b][1] += dp[k][1]
    dp = dp_new

mod = int(1e9) + 7
print(((4 ** N - sum([dp[k][1] for k in dp])) % mod))


# Optimized solution
# -*- coding: utf-8 -*-

N = int(eval(input()))

dp = {b: 1 for b in "ACGT"}
for _ in range(N - 1):
    dp_new = {}
    for k in dp:
        for b in "ACGT":
            n = k[-3:] + b
            if n[-3:] in ("AGC", "ACG", "GAC") or n in ("ACGC", "AGGC", "ATGC", "AGCC", "AGGC", "AGTC"):
                continue
            else:
                if n in dp_new:
                    dp_new[n] += dp[k]
                else:
                    dp_new[n] = dp[k]
    dp = dp_new

print((sum(dp.values()) % (10 ** 9 + 7)))
# Original solution
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')))

# Optimized solution
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))
# Original solution
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)

# Optimized solution
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))
# Original solution
from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 7)

N = int(eval(input()))
MOD = 10**9 + 7

def isOk(T):
    for i in range(4):
        t = list(T)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if 'AGC' in ''.join(t):
            return False
    return True

@lru_cache(maxsize=None)
def search(n, prev):
    if n == 0:
        return 1

    ret = 0
    for s in ['A', 'G', 'C', 'T']:
        t = (prev + s)[1:]
        if isOk(t):
            ret += search(n - 1, t)
            ret %= MOD

    return ret

print((search(N, 'ZZZZ')))

# Optimized solution
from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)

N = int(eval(input()))
MOD = 10**9 + 7
S = ['A', 'G', 'C', 'T']
M = set(['AGC', 'GAC', 'ACG'])

for s in S:
    M.add(s + 'AGC')
    M.add(s + 'GAC')
    M.add(s + 'ACG')
    M.add('A' + s + 'GC')
    M.add('AG' + s + 'C')

@lru_cache(maxsize=None)
def search(prev, length):
    if length >= N:
        return 1

    ret = 0

    for s in S:
        T = prev + s
        if not T in M:
            T = T[:: -1][: 3][:: -1]
            ret += search(T, length + 1)
    return ret % MOD

ans = search('', 0)
print(ans)
# Original solution
N, MOD = int(eval(input())), 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 ['A', 'C', 'G', 'T']:
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret
print((dfs(0, 'TTT')))

# Optimized solution
N, MOD = int(eval(input())), 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 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret
print((dfs(0, 'TTT')))
# Original solution
N, MOD = int(eval(input())), 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 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret
print((dfs(0, 'TTT')))

# Optimized solution
N = int(eval(input()))
MOD = 10 ** 9 + 7
memo = [{} for _ in range(N)]
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 'AGC' in ''.join(t):
            return False
    return True
def dfs(cur, last3):
    if cur == N:
        return 1
    elif last3 in memo[cur]:
        return memo[cur][last3]
    else:
        ret = 0
        for c in 'ACGT':
            if ok(last3 + c):
                ret += dfs(cur + 1, last3[1:] + c)
        ret = ret % MOD
        memo[cur][last3] = ret
        return ret
print((dfs(0, '   ')))
# Original solution
n = int(eval(input()))

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


#a,g,c =0,1,2
##末尾4文字見る必要がある。3文字ではない

def test(w,x,y,z):
    s = ((0,1,2),(1,0,2),(0,2,1))
    if (x,y,z) not in s and (w,y,z)!=(0,1,2) and (w,x,z)!=(0,1,2):##これ手でノーミスは無理なのだが、処理の実装を思いつく気がしない
        return True
    else:
        return False

for i in range(64):
    x,y,z = i>>4,(i>>2)&3,i&3
    if test(3,x,y,z):
        dp[2][i]=1

for i in range(3,n):
    for j in range(64):
        w,x,y = j>>4,(j>>2)&3,j&3
        """
        if w not in (0,1,2,3) or x not in (0,1,2,3) or y not in ( 0,1,2,3):
            print(j,w,x,y)
            exit()
        """
        for z in range(4):
            if test(w,x,y,z):
                dp[i][(x<<4)+(y<<2)+z]+=dp[i-1][j]

#for i in range(16):
#    ans+=dp[i][n-1]
ans = sum(dp[n-1])
ans%=10**9+7
print(ans)


# Optimized solution
n = int(eval(input()))

dp = [0]*64
#dpの保持変更

#a,g,c =0,1,2
##末尾4文字見る必要がある。3文字ではない

def test(w,x,y,z):
    s = ((0,1,2),(1,0,2),(0,2,1))
    if (x,y,z) not in s and (w,y,z)!=(0,1,2) and (w,x,z)!=(0,1,2):##これ手でノーミスは無理なのだが、処理の実装を思いつく気がしない
        return True
    else:
        return False

for i in range(64):
    x,y,z = i>>4,(i>>2)&3,i&3
    if test(3,x,y,z):
        dp[i]=1

for i in range(3,n):
    dp2 = [0]*64
    for j in range(64):
        w,x,y = j>>4,(j>>2)&3,j&3
        """
        if w not in (0,1,2,3) or x not in (0,1,2,3) or y not in ( 0,1,2,3):
            print(j,w,x,y)
            exit()
        """
        for z in range(4):
            if test(w,x,y,z):
                dp2[(x<<4)+(y<<2)+z]+=dp[j]
    dp = dp2

#for i in range(16):
#    ans+=dp[i][n-1]
ans = sum(dp)
ans%=10**9+7
print(ans)
# Original solution
from functools import lru_cache
N = int(eval(input()))
mod = 10**9+7

def check(s):
    for i in range(4):
        l=list(s)
        if i>0:
            l[i-1],l[i]=l[i],l[i-1]
        if "".join(l).count("AGC"):
            return False
    else:
        return True

@lru_cache(maxsize=None)
def dfp(i,seq):
    ret=0
    if i==N:
        return 1
    for s in ["A","G","C","T"]:
        if check(seq+s):
            ret=(ret+dfp(i+1,seq[1:]+s))%mod
    return ret

print((dfp(0,"TTT")))

# Optimized solution
N = int(eval(input()))
mod = 10**9+7

def check(s):
    for i in range(4):
        l=list(s)
        if i>0:
            l[i-1],l[i]=l[i],l[i-1]
        if "".join(l).count("AGC"):
            return False
    else:
        return True

memo=[dict() for _ in range(N)]
def dfp(i,seq):
    if i==N:
        return 1
    if seq in memo[i]:
        return memo[i][seq]
    ret=0
    for s in ["A","G","C","T"]:
        if check(seq+s):
            ret=(ret+dfp(i+1,seq[1:]+s))%mod
    memo[i][seq] = ret
    return ret

print((dfp(0,"TTT")))
# Original solution
"""
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))

# Optimized solution
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))