N = int(eval(input()))

mod = 10 ** 9 + 7

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

#print (memo)





#4文字を与えて条件に合致するかを判断

def check(last4):

    for i in range(4):

        t = list(last4) #4文字をリストに格納

        if i >= 1: #最初の文字以外に着目する時

            t[i-1], t[i] = t[i], t[i-1] #i番目とi-1番目を交換

        if ''.join(t).count('AGC') >= 1: #AGCが含まれているかどうかの確認

            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 'ATCG':

        if check(last3+c):

            ret = (ret+dfs(cur+1, last3[1:]+c))%mod

    memo[cur][last3] = ret

    return ret



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





#print (memo)
N = int(eval(input()))

MOD = 10 ** 9 + 7



memo = [{} for _ 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 'AGCT':

        if ok(last3 + c):

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

    memo[cur][last3] = ret

    return ret



print((dfs(0, 'TTT')))
N = int(eval(input()))
mod = 10**9 + 7
memo = [{} for i in range(N + 1)]
# print (memo)
# 4文字を与えて条件に合致するかを判断
def check(last4):
    for i in range(4):
        t = list(last4)  # 4文字をリストに格納
        if i >= 1:  # 最初の文字以外に着目する時
            t[i - 1], t[i] = t[i], t[i - 1]  # i番目とi-1番目を交換
        if "".join(t).count("AGC") >= 1:  # AGCが含まれているかどうかの確認
            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 "ATCG":
        if check(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % mod
    memo[cur][last3] = ret
    return ret


print((dfs(0, "TTT")))
# print (memo)

N = int(eval(input()))
MOD = 10**9 + 7
memo = [{} for _ 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 "AGCT":
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret


print((dfs(0, "TTT")))

-mod = 10**9 + 7 -memo = [{} for i in range(N + 1)] -# print (memo) -# 4文字を与えて条件に合致するかを判断 -def check(last4): +MOD = 10**9 + 7 +memo = [{} for _ in range(N + 1)] + + +def ok(last4): -        t = list(last4)  # 4文字をリストに格納 -        if i >= 1:  # 最初の文字以外に着目する時 -            t[i - 1], t[i] = t[i], t[i - 1]  # i番目とi-1番目を交換 -        if "".join(t).count("AGC") >= 1:  # AGCが含まれているかどうかの確認 +        t = list(last4) +        if i >= 1: +            t[i - 1], t[i] = t[i], t[i - 1] +        if "".join(t).count("AGC") >= 1: -def dfs(cur, last3):  # 深さ優先探索 +def dfs(cur, last3): -    for c in "ATCG": -        if check(last3 + c): -            ret = (ret + dfs(cur + 1, last3[1:] + c)) % mod +    for c in "AGCT": +        if ok(last3 + c): +            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD -# print (memo)