s = input()
s1 = s[:2]
s2 = s[2:4]
r = int(s2)
l = int(s1)

if(1<=r<=12 and 1<=l<=12):
    print("AMBIGUOUS")
elif((r > 12 or r == 0) and 1 <= l <= 12):
    print("MMYY")
elif((l >= 12 or l == 0) and 1 <= r <= 12):
    print("YYMM")
else:
    print("NA")

 s = input() s input() input s1 = s[:2] s1 s[:2] s :2 2 s2 = s[2:4] s2 s[2:4] s 2:4 2 4 r = int(s2) r int(s2) int s2 l = int(s1) l int(s1) int s1 if(1<=r<=12 and 1<=l<=12):
    print("AMBIGUOUS")
elif((r > 12 or r == 0) and 1 <= l <= 12):
    print("MMYY")
elif((l >= 12 or l == 0) and 1 <= r <= 12):
    print("YYMM")
else:
    print("NA") 1<=r<=12 and 1<=l<=12 1<=r<=12 1<=r 1 r 12 1<=l<=12 1<=l 1 l 12 print("AMBIGUOUS") print "AMBIGUOUS" elif((r > 12 or r == 0) and 1 <= l <= 12):
    print("MMYY") (r > 12 or r == 0) and 1 <= l <= 12 r > 12 or r == 0 r > 12 r 12 r == 0 r 0 1 <= l <= 12 1 <= l 1 l 12 print("MMYY") print "MMYY" elif((l >= 12 or l == 0) and 1 <= r <= 12):
    print("YYMM") (l >= 12 or l == 0) and 1 <= r <= 12 l >= 12 or l == 0 l >= 12 l 12 l == 0 l 0 1 <= r <= 12 1 <= r 1 r 12 print("YYMM") print "YYMM" print("NA") print "NA" s2 = s[2:4] s[2:4] s2 l = int(s1) int(s1) l r = int(s2) int(s2) r s = input() input() s s1 = s[:2] s[:2] s1
s = input()
s1 = s[:2]
s2 = s[2:4]
r = int(s2)
l = int(s1)

if(1<=r<=12 and 1<=l<=12):
    print("AMBIGUOUS")
elif((r > 12 or r == 0) and 1 <= l <= 12):
    print("MMYY")
elif((l >= 12 or l == 0) and 1 <= r <= 12):
    print("YYMM")
else:
    print("NA")


