s = input()

flag=[0,0]

if 1<=int(s[0:2])<=12:
    flag[0]=1
if 1<=int(s[2:4])<=12:
    flag[1]=1

if flag==[0,0]:
    print("NA")
if flag==[1,0]:
    print("MMYY")
if flag==[0,1]:
    print("YYMM")
if flag==[1,1]:
    print("AMBIGUOUS") s = input() s input() input flag=[0,0] flag [0,0] 0 0 if 1<=int(s[0:2])<=12:
    flag[0]=1 1<=int(s[0:2])<=12 1<=int(s[0:2]) 1 int(s[0:2]) int s[0:2] s 0:2 0 2 12 flag[0]=1 flag[0] flag 0 1 if 1<=int(s[2:4])<=12:
    flag[1]=1 1<=int(s[2:4])<=12 1<=int(s[2:4]) 1 int(s[2:4]) int s[2:4] s 2:4 2 4 12 flag[1]=1 flag[1] flag 1 1 if flag==[0,0]:
    print("NA") flag==[0,0] flag [0,0] 0 0 print("NA") print "NA" if flag==[1,0]:
    print("MMYY") flag==[1,0] flag [1,0] 1 0 print("MMYY") print "MMYY" if flag==[0,1]:
    print("YYMM") flag==[0,1] flag [0,1] 0 1 print("YYMM") print "YYMM" if flag==[1,1]:
    print("AMBIGUOUS") flag==[1,1] flag [1,1] 1 1 print("AMBIGUOUS") print "AMBIGUOUS" flag=[0,0] [0,0] flag s = input() input() s
s = input()

flag=[0,0]

if 1<=int(s[0:2])<=12:
    flag[0]=1
if 1<=int(s[2:4])<=12:
    flag[1]=1

if flag==[0,0]:
    print("NA")
if flag==[1,0]:
    print("MMYY")
if flag==[0,1]:
    print("YYMM")
if flag==[1,1]:
    print("AMBIGUOUS")
