CodeEff/ECCO huggingface dataset:
# Original solution
# 2019-11-13 01:53:22(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    first, second = int(s[:2]), int(s[2:])
    if 1 <= first <= 12:
        if 1 <= second <= 12:
            ans = 'AMBIGUOUS'
        else:
            ans = 'MMYY'
    else:
        if 1 <= second <= 12:
            ans = 'YYMM'
        else:
            ans = 'NA'
    print(ans)



if __name__ == "__main__":
    main()


# Optimized solution
import sys

s = sys.stdin.readline().rstrip()

def main():
    a, b = int(s[:2]), int(s[2:])
    if 1 <= a <= 12:
        if 1 <= b <= 12:
            return 'AMBIGUOUS'
        else:
            return 'MMYY'
    else:
        if 1 <= b <= 12:
            return 'YYMM'
        else:
            return 'NA'

if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
while 1:
	r,c,q = list(map(int,input().split()))
	if r == 0: break
	R = [[0,0] for i in range(r)]
	C = [[0,0] for i in range(c)]
	for i in range(1,q+1):
		A,B,order = list(map(int,input().split()))
		if A == 0:
			R[B] = [i,order]
		else:
			C[B] = [i,order]
	ans = 0
	for ri in range(r):
		ans += sum(R[ri][1] if R[ri][0] > C[ci][0] else C[ci][1] for ci in range(c))
	print(ans)

# Optimized solution
import bisect
while 1:
	r,c,q = list(map(int,input().split()))
	if r == 0: break
	R = [[0,0] for i in range(r)]
	C = [[0,0] for i in range(c)]
	for i in range(1,q+1):
		A,B,order = list(map(int,input().split()))
		if A == 0:
			R[B] = [i,order]
		else:
			C[B] = [i,order]
	c1 = sorted(C[ci][0] for ci in range(c) if C[ci][1] == 1)
	c0 = sorted(C[ci][0] for ci in range(c) if C[ci][1] == 0)
	ans = r*sum(C[ci][1] for ci in range(c))
	for ri in range(r):
		if R[ri][1] == 0:
			ans -= bisect.bisect(c1,R[ri][0])
		else:
			ans += bisect.bisect(c0,R[ri][0])
	print(ans)
# Original solution
s=input()
print(s.upper())

# Optimized solution
print(input().upper())
# Original solution
def bowling(game):
	game=list(map(int,game.split()))
	score,thrw=0,1
	for flame in range(10):
		if game[thrw]==10:
			score+=sum(game[thrw:thrw+3])
			thrw+=1
		elif game[thrw]+game[thrw+1]==10:
			score+=10+game[thrw+2]
			thrw+=2
		else:
			score+=game[thrw]+game[thrw+1]
			thrw+=2
	return game[0],score
	
while 1:
	n=eval(input())
	if n==0:break
	ls=[bowling(input()) for i in range(n)]
	for k,s in sorted(sorted(ls),key=lambda x:x[1],reverse=True):
		print(k,s)

# Optimized solution
def bowling(game):
	game=list(map(int,game.split()))
	score,thrw=0,1
	for flame in range(10):
		if game[thrw]==10:
			score+=sum(game[thrw:thrw+3])
			thrw+=1
		elif game[thrw]+game[thrw+1]==10:
			score+=10+game[thrw+2]
			thrw+=2
		else:
			score+=sum(game[thrw:thrw+2])
			thrw+=2
	return game[0],score
	
while 1:
	n=eval(input())
	if n==0:break
	ls=[bowling(input()) for i in range(n)]
	for k,s in sorted(sorted(ls),key=lambda x:x[1],reverse=1):
		print(k,s)
# Original solution
import pprint
n = int(eval(input()))
dp = [{} for i in range(n + 1)]
s = "AGCT"
M = 10 ** 9 + 7

for j in range(n + 1):
  for c1 in s:
    for c2 in s:
      for c3 in s:
        dp[j][c1 + c2 + c3] = 0

dp[0]["TTT"] = 1

for l in range(n):
  for c1 in s:
    for c2 in s:
      for c3 in s:
        for p in s:
          if c2 == "A" and c3 == "G" and p == "C":
            continue
          if c1 == "A" and c3 == "G" and p == "C":
            continue
          if c1 == "A" and c2 == "G" and p == "C":
            continue
          if c2 == "G" and c3 == "A" and p == "C":
            continue
          if c2 == "A" and c3 == "C" and p == "G":
            continue
          dp[l + 1][c2 + c3 + p] += dp[l][c1 + c2 + c3]
          dp[l + 1][c2 + c3 + p] = dp[l + 1][c2 + c3 + p] % M

ans = 0
for c1 in s:
  for c2 in s:
    for c3 in s:
      ans += dp[n][c1 + c2 + c3]
      ans = ans % M
print(ans)


# Optimized solution
import pprint
n = int(eval(input()))
dp = [{} for i in range(n + 1)]
s = "AGCT"
M = 10 ** 9 + 7

for j in range(n + 1):
  for c1 in s:
    for c2 in s:
      for c3 in s:
        dp[j][c1 + c2 + c3] = 0

dp[0]["TTT"] = 1

for l in range(n):
  for c1 in s:
    for c2 in s:
      for c3 in s:
        for p in s:
          if c2 == "A" and c3 == "G" and p == "C":
            continue
          if c1 == "A" and c3 == "G" and p == "C":
            continue
          if c1 == "A" and c2 == "G" and p == "C":
            continue
          if c2 == "G" and c3 == "A" and p == "C":
            continue
          if c2 == "A" and c3 == "C" and p == "G":
            continue
          dp[l + 1][c2 + c3 + p] = (dp[l + 1][c2 + c3 + p] + dp[l][c1 + c2 + c3]) % M
          

ans = 0
for c1 in s:
  for c2 in s:
    for c3 in s:
      ans += dp[n][c1 + c2 + c3]
      ans = ans % M
print(ans)
# Original solution
from functools import lru_cache


def check(s):
    bads = ["AGC", "ACG", "GAC"] + [b.format(_s) for b in ["AG{}C", "A{}GC"] for _s in "ACGT"]
    return not any([x in s for x in bads])


def solve(string):
    n = int(string)

    @lru_cache(n * 4**3)
    def dfs(pos, last3):
        if pos == n:
            return 1
        ans = 0
        for _s in "ACGT":
            ans += dfs(pos + 1, last3[1:] + _s) if check(last3 + _s) else 0
        return ans % (10**9 + 7)

    return str(dfs(0, "TTT"))


if __name__ == '__main__':
    print((solve(eval(input()))))


# Optimized solution
def solve(string):
    n = int(string)
    dp = [[0] * 4 for _ in range(n)]
    dp[0] = [1] * 4
    for i in range(1, n):
        base = sum(dp[i - 1])
        for j in range(4):
            dp[i][j] = base
        # "AGC", "ACG", "GAC"
        if i >= 2:
            dp[i][1] -= dp[i - 2][0] + dp[i - 2][2]
            dp[i][2] -= dp[i - 2][0]
        # "AG{}C", "A{}GC"
        if i >= 3:
            dp[i][1] -= dp[i - 3][0] * 3
            dp[i][2] += dp[i - 3][2]

    return str(sum(dp[n - 1]) % (10**9 + 7))


if __name__ == '__main__':
    print((solve(eval(input()))))
# Original solution
N = int(eval(input()))

MOD = 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 + 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") > 0:
            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 = int(eval(input()))

dp = [[0]*16 for i in range(n)]
for j in range(16):
  if j in [1,6,9]:
    dp[1][j] = 1
  else:
    dp[1][j] = 1

for i in range(2,n):
  for j in range(16):
    k = j//4
    dp[i][j] = dp[i-1][k]+dp[i-1][k+4]+dp[i-1][k+8]+dp[i-1][k+12]
    if j == 1:
      dp[i][j] -= dp[i-1][8]
    elif j == 6:
      dp[i][j] -= dp[i-1][1]
    elif j == 9:
      dp[i][j] -= dp[i-1][2]+dp[i-2][2]+dp[i-2][3]
    elif j == 13:
      dp[i][j] -= dp[i-2][2]
    else:
      continue

count = 0
for j in range(16):
  count += dp[n-1][j]

print((count%1000000007))

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

dp = [[0]*16 for i in range(n)]
for j in range(16):
  dp[1][j] = 1

for i in range(2,n):
  for j in range(16):
    k = j//4
    dp[i][j] = dp[i-1][k]+dp[i-1][k+4]+dp[i-1][k+8]+dp[i-1][k+12]
    if j == 1:
      dp[i][j] -= dp[i-1][8]
    elif j == 6:
      dp[i][j] -= dp[i-1][1]
    elif j == 9:
      dp[i][j] -= dp[i-1][2]+dp[i-2][2]+dp[i-2][3]
    elif j == 13:
      dp[i][j] -= dp[i-2][2]
    else:
      continue

count = 0
for j in range(16):
  count += dp[n-1][j]

print((count%1000000007))
# Original solution
from itertools import product
import re
N = int(eval(input()))
MOD = 10 ** 9 + 7


dp = [{''.join(last_3): 0 for last_3 in product('AGCT', repeat=3)} for i in range(N + 1)]
dp[0]['TTT'] = 1
NG_pattern = r'.*AGC|.*ACG|.*GAC|A.GC|AG.C|'


for i in range(1, N + 1):
    for last_3 in product('AGCT', repeat=3):
        last_3 = ''.join(last_3)
        for pre_s in 'AGCT':
            if re.match(NG_pattern, pre_s + last_3).group():
                continue
            else:
                dp[i][pre_s + last_3[:-1]] += dp[i - 1][last_3]
                dp[i][pre_s + last_3[:-1]] %= MOD

print((sum(dp[-1].values()) % MOD))


# Optimized solution
from itertools import product
import re

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

dp = [{''.join(last_3): 0 for last_3 in product('AGCT', repeat=3)} for i in range(N + 1)]
dp[0]['TTT'] = 1
NG_pattern = r'.*AGC|.*ACG|.*GAC|A.GC|AG.C|'

for i in range(N):
    for last_3 in product('AGCT', repeat=3):
        last_3 = ''.join(last_3)
        for next_s in 'AGCT':
            if re.match(NG_pattern, last_3 + next_s).group():
                continue
            else:
                dp[i + 1][last_3[1:] + next_s] += dp[i][last_3]
                dp[i + 1][last_3[1:] + next_s] %= MOD

print((sum(dp[-1].values()) % MOD))
# Original solution
MOD=10**9+7
N=int(eval(input()))
if N==3:
  print((61))
  exit()
  
dp=[[[[1]*4 for c in range(4)] for b in range(4)] for a in range(4)]
        
for x in range(4):
  dp[0][x][2][1]=0
  dp[0][2][x][1]=0
  dp[0][1][2][x]=0
  dp[2][0][1][x]=0
  dp[0][2][1][x]=0
  dp[x][0][1][2]=0
  dp[x][2][0][1]=0
  dp[x][0][2][1]=0
  
def f():
  tmp=[[[[0]*4 for c in range(4)] for b in range(4)] for a in range(4)]
  for a in range(4):
    for b in range(4):
      for c in range(4):
        t=sum([dp[x][a][b][c] for x in range(4)])
        t%=MOD
        for d in range(4):
          tmp[a][b][c][d]=t
          
  for x in range(4):
    tmp[0][x][2][1]=0
    tmp[0][2][x][1]=0
    tmp[x][0][1][2]=0
    tmp[x][2][0][1]=0
    tmp[x][0][2][1]=0
    
  return tmp
  
for k in range(4, N):
  dp=f()
  
print((sum([dp[a][b][c][d] for a in range(4) for b in range(4) for c in range(4) for d in range(4)])%MOD))

# Optimized solution
MOD=10**9+7
N=int(eval(input()))
if N==3:
  print((61))
  exit()
  
dp=[[[[1]*4 for c in range(4)] for b in range(4)] for a in range(4)]
        
for x in range(4):
  dp[0][x][2][1]=0
  dp[0][2][x][1]=0
  dp[0][1][2][x]=0
  dp[2][0][1][x]=0
  dp[0][2][1][x]=0
  dp[x][0][1][2]=0
  dp[x][2][0][1]=0
  dp[x][0][2][1]=0
  
def f():
  tmp=[[[[0]*4 for c in range(4)] for b in range(4)] for a in range(4)]
  for a in range(4):
    for b in range(4):
      for c in range(4):
        t=sum([dp[x][a][b][c] for x in range(4)])
        t%=MOD
        for d in range(4):
          tmp[a][b][c][d]=t
          
  for x in range(4):
    tmp[0][x][2][1]=0
    tmp[0][2][x][1]=0
    tmp[x][0][1][2]=0
    tmp[x][2][0][1]=0
    tmp[x][0][2][1]=0
    
  return tmp
  
for k in range(4, N):
  dp=f()
  
print((sum([sum([dp[a][b][c][d] for a in range(4) for b in range(4) for c in range(4)])%MOD for d in range(4)])%MOD))
# Original solution
import re

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(eval(input()))

MOD = int(1e9) + 7

acgt = ["A", "C", "G", "T"]
changed = [".*AGC", ".*GAC", ".*ACG", ".*A.GC", ".*AG.C"]
abcl = [ a+b+c for a in acgt for b in acgt for c in acgt]

dp = {}
for now in abcl:
    if any([re.match(ch, now) for ch in changed]):
        dp[now] = 0
    else:
        dp[now] = 1

N -= 3

while N > 0:
    dpNow = {}
    for abc in abcl:
        abc = abc[:min(N, 3)]
        dpNow[abc] = 0
        for key, value in list(dp.items()):
            now = key + abc
            if not any([re.match(ch, now) for ch in changed]):
                dpNow[abc] += value
                dpNow[abc] %= MOD
    dp = dpNow
    N -= 3

ans = 0
for v in list(dp.values()):
    ans += v
    ans %= MOD

print(ans)


# Optimized solution
import re

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(eval(input()))

MOD = int(1e9) + 7

acgt = ["A", "C", "G", "T"]
changed = list([re.compile(pat) for pat in [r".*AGC", r".*GAC", r".*ACG", r".*A.GC", r".*AG.C"]])
abcl = [ a+b+c for a in acgt for b in acgt for c in acgt]

dp = {}
for now in abcl:
    if any([ch.match(now) for ch in changed]):
        dp[now] = 0
    else:
        dp[now] = 1

N -= 3

while N > 0:
    dpNow = {}
    for abc in abcl:
        abc = abc[:min(N, 3)]
        dpNow[abc] = 0
        for key, value in list(dp.items()):
            now = key + abc
            if not any([ch.match(now) for ch in changed]):
                dpNow[abc] += value
                dpNow[abc] %= MOD
    dp = dpNow
    N -= 3

ans = 0
for v in list(dp.values()):
    ans += v
    ans %= MOD

print(ans)
# Original solution
import re

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(eval(input()))

MOD = int(1e9) + 7

acgt = ["A", "C", "G", "T"]
changed = list([re.compile(pat) for pat in [r".*AGC", r".*GAC", r".*ACG", r".*A.GC", r".*AG.C"]])
abcl = [ a+b+c for a in acgt for b in acgt for c in acgt]

dp = {}
for now in abcl:
    if any([ch.match(now) for ch in changed]):
        dp[now] = 0
    else:
        dp[now] = 1

N -= 3

while N > 0:
    dpNow = {}
    for abc in abcl:
        abc = abc[:min(N, 3)]
        dpNow[abc] = 0
        for key, value in list(dp.items()):
            now = key + abc
            if not any([ch.match(now) for ch in changed]):
                dpNow[abc] += value
                dpNow[abc] %= MOD
    dp = dpNow
    N -= 3

ans = 0
for v in list(dp.values()):
    ans += v
    ans %= MOD

print(ans)


# Optimized solution
import re

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(eval(input()))

MOD = int(1e9) + 7

acgt = ["A", "C", "G", "T"]
changed = list([re.compile(pat) for pat in [r"AGC", r"GAC", r"ACG", r"A.GC", r"AG.C"]])
abcl = [ a+b+c for a in acgt for b in acgt for c in acgt]

dp = {}
for now in abcl:
    if any([ch.search(now) for ch in changed]):
        dp[now] = 0
    else:
        dp[now] = 1

N -= 3

while N > 0:
    dpNow = {}
    for abc in abcl:
        abc = abc[:min(N, 3)]
        dpNow[abc] = 0
        for key, value in list(dp.items()):
            now = key + abc
            if not any([ch.search(now) for ch in changed]):
                dpNow[abc] += value
                dpNow[abc] %= MOD
    dp = dpNow
    N -= 3

ans = 0
for v in list(dp.values()):
    ans += v
    ans %= MOD

print(ans)
# Original solution
#18:20
n = int(eval(input()))
mod = 10 ** 9 + 7
now = [[[[0 for _ in range(4)]
            for _ in range(4)]
            for _ in range(4)]
            for _ in range(4)]
now[3][3][3][3] = 1
for _ in range(n):
  last = now
  now = [[[[0 for _ in range(4)]
              for _ in range(4)]
              for _ in range(4)]
              for _ in range(4)]
  for i in range(4):
    for j in range(4):
      for k in range(4):
        for l in range(4):
          for m in range(4):
            now[j][k][l][m] += last[i][j][k][l]
            now[j][k][l][m] %= mod
  for j in range(4):
    now[j][0][1][2] = 0
    now[j][1][0][2] = 0
    now[j][0][2][1] = 0
  for k in range(4):
    now[0][k][1][2] = 0
  for l in range(4):
    now[0][1][l][2] = 0
ans = 0
for i in range(4):
  for j in range(4):
    for k in range(4):
      for l in range(4):
        ans += now[i][j][k][l]
print((ans % mod))

# Optimized solution
n = int(eval(input()))
mod = 10 ** 9 + 7
now = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(4)]
now[3][3][3][3] = 1
for _ in range(n):
  last = now
  now = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(4)]
  for i in range(4):
    for j in range(4):
      for k in range(4):
        for l in range(4):
          for m in range(4):
            now[j][k][l][m] += last[i][j][k][l]
            now[j][k][l][m] %= mod
  for h in range(4):
    now[h][0][1][2] = 0
    now[h][1][0][2] = 0
    now[h][0][2][1] = 0
    now[0][h][1][2] = 0
    now[0][1][h][2] = 0
ans = 0
for j in range(4):
  for k in range(4):
    for l in range(4):
      for m in range(4):
        ans += now[j][k][l][m]
        ans %= mod
print(ans)
# Original solution
import itertools
L = [''.join(i) for i in itertools.product('0123', repeat=3)]
l = len(L)

mod = 10**9+7

AGC = '021'
ACG = '012'
GAC = '201'
nc3 = set([AGC, ACG, GAC])

AGGC = '0221'
AGTC = '0231'
ATGC = '0321'
nc4 = set([AGGC, AGTC, ATGC])

n = int(eval(input()))
dp = [[0]*l for _ in range(n+1)]
for i in L:
  if i in nc3: continue
  dp[3][int(i, 4)] = 1

for i in range(3, n):
  for jl in L:
    for k in "0123":
      nxt = jl[1:] + k
      if nxt in nc3: continue
      if jl+k in nc4: continue
      dp[i+1][int(nxt, 4)] += dp[i][int(jl, 4)]
print((sum(dp[n])%mod))

# Optimized solution
#!/usr/bin python3
# -*- coding: utf-8 -*-

import itertools
L = [''.join(i) for i in itertools.product('0123', repeat=3)]
l = len(L)

mod = 10**9+7

AGC = '021'
ACG = '012'
GAC = '201'
nc3 = set([AGC, ACG, GAC])

AGGC = '0221'
AGTC = '0231'
ATGC = '0321'
nc4 = set([AGGC, AGTC, ATGC])

n = int(eval(input()))
dp = [[0]*l for _ in range(n+1)]
for i in L:
    if i in nc3: continue
    dp[3][int(i, 4)] = 1

for i in range(3, n):
    for jl in L:
        for k in "0123":
            nxt = jl[1:] + k
            if nxt in nc3: continue
            if jl+k in nc4: continue
            dp[i+1][int(nxt, 4)] += dp[i][int(jl, 4)]
print((sum(dp[n])%mod))
# Original solution
#!/usr/bin/env python3
#ABC122 D

#条件を満たさないものは以下の5通りで追加する文字列+3文字を見れば決まる
#ACG,GAC,AGC,A?GC,AG?C
n = int(eval(input()))
#メモ化再帰
memo = [{} for i in range(n+1)]
mod = 10**9 + 7

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
    #AGCTを1文字ずつ追加してみる
    for c in 'AGCT':
        #cを追加したときにTrue(不適でない)なら
        if ok(last3 + c):
            #現在位置を1つ進めてcを追加した値を足す
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % mod
    #値を格納
    memo[cur][last3] = ret
    return ret
print((dfs(0,'TTT')))


# Optimized solution
#!/usr/bin/env python3
#ABC122 D
n = int(eval(input()))
mod = 10**9+7

dp = [[[[0]*4 for _ in range(4)] for _ in range(4)] for _ in range(n+1)]
#長さ0の文字列は1
#0,1,2(A,G,C)に関する制約しかないため
#Sは、TTTSと考えてもよい
dp[0][3][3][3] = 1

#swapしてAGCが発生しない文字列:=AGC,ACG,GAC,A?GC,AG?Cを含まない文字列
#A:=0,G:=1,C:=2,T:=3

#文字列の文字数
for i in range(n):
    #最後から1文字目
    for j in range(4):
        #最後から2文字目
        for k in range(4):
            #条件に当てはまるものがない場合
            if dp[i][j][k] == 0:
                continue
            #最後から3文字目
            for l in range(4):
                #新たに追加する文字
                for a in range(4):
                    #ダメな5条件をカット

                    #AGCの場合
                    if a == 2 and j == 1 and k == 0:continue
                    #GACの場合
                    if a == 2 and j == 0 and k == 1:continue
                    #ACGの場合
                    if a == 1 and j == 2 and k == 0:continue
                    #A?GCの場合
                    if a == 2 and j == 1 and l == 0:continue
                    #AG?Cの場合
                    if a == 2 and k == 1 and l == 0:continue

                    #ダメの条件を抜けると、aを足した文字列が作れる
                    dp[i+1][a][j][k] += dp[i][j][k][l]
                    dp[i+1][a][j][k] %= mod

ans = 0
for j in range(4):
    for k in range(4):
        for l in range(4):
            #長さnの全通り回収
            ans += dp[n][j][k][l]
            ans %= mod
print(ans)
# Original solution
from collections import defaultdict
N = int(eval(input()))
dp = [defaultdict(int) for _ in range(N+1)]
MOD = 10**9 + 7
dp[0]['TTT'] = 1


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


for n in range(N):
    for s, cnt in list(dp[n].items()):
        for c in 'AGCT':
            ns = s+c
            if ok(ns):
                dp[n+1][ns[-3:]] = (dp[n+1][ns[-3:]]+cnt) % MOD

print((sum(dp[N].values()) % MOD))


# Optimized solution
# ABC122D - We Like AGC
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 = 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)

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