s = input()
v=0
for i in range(4):
    v = v*10+int(s[i])
v1 = v//100
v2 = v%100
if 12>=v1>=1 and 12>=v2>=1:
    print("AMBIGUOUS")
elif (v1>=13 or v1==0) and 12>=v2>=1:
    print("YYMM")
elif (v2>=13 or v2==0) and 12>=v1>=1:
    print("MMYY")
else:
    print("NA") s = input() s input() input v=0 v 0 for i in range(4):
    v = v*10+int(s[i]) i range(4) range 4 v = v*10+int(s[i]) v v*10+int(s[i]) v*10 v 10 int(s[i]) int s[i] s i v1 = v//100 v1 v//100 v 100 v2 = v%100 v2 v%100 v 100 if 12>=v1>=1 and 12>=v2>=1:
    print("AMBIGUOUS")
elif (v1>=13 or v1==0) and 12>=v2>=1:
    print("YYMM")
elif (v2>=13 or v2==0) and 12>=v1>=1:
    print("MMYY")
else:
    print("NA") 12>=v1>=1 and 12>=v2>=1 12>=v1>=1 12>=v1 12 v1 1 12>=v2>=1 12>=v2 12 v2 1 print("AMBIGUOUS") print "AMBIGUOUS" elif (v1>=13 or v1==0) and 12>=v2>=1:
    print("YYMM") (v1>=13 or v1==0) and 12>=v2>=1 v1>=13 or v1==0 v1>=13 v1 13 v1==0 v1 0 12>=v2>=1 12>=v2 12 v2 1 print("YYMM") print "YYMM" elif (v2>=13 or v2==0) and 12>=v1>=1:
    print("MMYY") (v2>=13 or v2==0) and 12>=v1>=1 v2>=13 or v2==0 v2>=13 v2 13 v2==0 v2 0 12>=v1>=1 12>=v1 12 v1 1 print("MMYY") print "MMYY" print("NA") print "NA" v2 = v%100 v%100 v2 v1 = v//100 v//100 v1 s = input() input() s v=0 0 v v = v*10+int(s[i]) v*10+int(s[i]) v
s = input()
v=0
for i in range(4):
    v = v*10+int(s[i])
v1 = v//100
v2 = v%100
if 12>=v1>=1 and 12>=v2>=1:
    print("AMBIGUOUS")
elif (v1>=13 or v1==0) and 12>=v2>=1:
    print("YYMM")
elif (v2>=13 or v2==0) and 12>=v1>=1:
    print("MMYY")
else:
    print("NA")