from itertools import product
s=input()
y=["0","1","2","3","4","5","6","7","8","9"]
yy=list((x+y for x,y in product(y,repeat=2)))
mm=["01","02","03","04","05","06","07","08","09","10","11","12"]

ans="NA"
if (s[0:2] in yy and s[2:4] in mm) and (s[0:2] not in mm or  s[2:4]  not in yy):
    ans="YYMM"
elif (s[0:2] in mm and s[2:4] in yy) and (s[0:2] not in yy or  s[2:4]  not in mm):
    ans="MMYY"
elif (s[0:2] in mm and s[2:4] in yy) and (s[0:2] in yy or  s[2:4]  in mm):
    ans="AMBIGUOUS"

print(ans) from itertools import product s=input() s input() input y=["0","1","2","3","4","5","6","7","8","9"] y ["0","1","2","3","4","5","6","7","8","9"] "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" x+y for x,y in product(y,repeat=2) for x,y in product(y,repeat=2) x y product(y,repeat=2) product y repeat=2 repeat 2 for x,y in product(y,repeat=2) x+y x y yy=list((x+y for x,y in product(y,repeat=2))) yy list((x+y for x,y in product(y,repeat=2))) list (x+y for x,y in product(y,repeat=2)) mm=["01","02","03","04","05","06","07","08","09","10","11","12"] mm ["01","02","03","04","05","06","07","08","09","10","11","12"] "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" ans="NA" ans "NA" if (s[0:2] in yy and s[2:4] in mm) and (s[0:2] not in mm or  s[2:4]  not in yy):
    ans="YYMM"
elif (s[0:2] in mm and s[2:4] in yy) and (s[0:2] not in yy or  s[2:4]  not in mm):
    ans="MMYY"
elif (s[0:2] in mm and s[2:4] in yy) and (s[0:2] in yy or  s[2:4]  in mm):
    ans="AMBIGUOUS" (s[0:2] in yy and s[2:4] in mm) and (s[0:2] not in mm or  s[2:4]  not in yy) s[0:2] in yy and s[2:4] in mm s[0:2] in yy s[0:2] s 0:2 0 2 yy s[2:4] in mm s[2:4] s 2:4 2 4 mm s[0:2] not in mm or  s[2:4]  not in yy s[0:2] not in mm s[0:2] s 0:2 0 2 mm s[2:4]  not in yy s[2:4] s 2:4 2 4 yy ans="YYMM" ans "YYMM" elif (s[0:2] in mm and s[2:4] in yy) and (s[0:2] not in yy or  s[2:4]  not in mm):
    ans="MMYY" (s[0:2] in mm and s[2:4] in yy) and (s[0:2] not in yy or  s[2:4]  not in mm) s[0:2] in mm and s[2:4] in yy s[0:2] in mm s[0:2] s 0:2 0 2 mm s[2:4] in yy s[2:4] s 2:4 2 4 yy s[0:2] not in yy or  s[2:4]  not in mm s[0:2] not in yy s[0:2] s 0:2 0 2 yy s[2:4]  not in mm s[2:4] s 2:4 2 4 mm ans="MMYY" ans "MMYY" elif (s[0:2] in mm and s[2:4] in yy) and (s[0:2] in yy or  s[2:4]  in mm):
    ans="AMBIGUOUS" (s[0:2] in mm and s[2:4] in yy) and (s[0:2] in yy or  s[2:4]  in mm) s[0:2] in mm and s[2:4] in yy s[0:2] in mm s[0:2] s 0:2 0 2 mm s[2:4] in yy s[2:4] s 2:4 2 4 yy s[0:2] in yy or  s[2:4]  in mm s[0:2] in yy s[0:2] s 0:2 0 2 yy s[2:4]  in mm s[2:4] s 2:4 2 4 mm ans="AMBIGUOUS" ans "AMBIGUOUS" print(ans) print ans ans="MMYY" "MMYY" ans mm=["01","02","03","04","05","06","07","08","09","10","11","12"] ["01","02","03","04","05","06","07","08","09","10","11","12"] mm ans="NA" "NA" ans s=input() input() s y=["0","1","2","3","4","5","6","7","8","9"] ["0","1","2","3","4","5","6","7","8","9"] y ans="YYMM" "YYMM" ans ans="AMBIGUOUS" "AMBIGUOUS" ans yy=list((x+y for x,y in product(y,repeat=2))) list((x+y for x,y in product(y,repeat=2))) yy
from itertools import product
s=input()
y=["0","1","2","3","4","5","6","7","8","9"]
yy=list((x+y for x,y in product(y,repeat=2)))
mm=["01","02","03","04","05","06","07","08","09","10","11","12"]

ans="NA"
if (s[0:2] in yy and s[2:4] in mm) and (s[0:2] not in mm or  s[2:4]  not in yy):
    ans="YYMM"
elif (s[0:2] in mm and s[2:4] in yy) and (s[0:2] not in yy or  s[2:4]  not in mm):
    ans="MMYY"
elif (s[0:2] in mm and s[2:4] in yy) and (s[0:2] in yy or  s[2:4]  in mm):
    ans="AMBIGUOUS"

print(ans)