s = input()

l = list(s)

x = int(l[0]+l[1])
y = int(l[2]+l[3])

if 0 < x < 13 and (y > 12 or y == 0):
    print("MMYY")
elif (x > 12 or x == 0) and 0 < y < 13:
    print("YYMM")
elif x > 12 or y > 12 or (x == 0 and y == 0):
    print("NA")
else:
    print("AMBIGUOUS") s = input() s input() input l = list(s) l list(s) list s x = int(l[0]+l[1]) x int(l[0]+l[1]) int l[0]+l[1] l[0] l 0 l[1] l 1 y = int(l[2]+l[3]) y int(l[2]+l[3]) int l[2]+l[3] l[2] l 2 l[3] l 3 if 0 < x < 13 and (y > 12 or y == 0):
    print("MMYY")
elif (x > 12 or x == 0) and 0 < y < 13:
    print("YYMM")
elif x > 12 or y > 12 or (x == 0 and y == 0):
    print("NA")
else:
    print("AMBIGUOUS") 0 < x < 13 and (y > 12 or y == 0) 0 < x < 13 0 < x 0 x 13 y > 12 or y == 0 y > 12 y 12 y == 0 y 0 print("MMYY") print "MMYY" elif (x > 12 or x == 0) and 0 < y < 13:
    print("YYMM") (x > 12 or x == 0) and 0 < y < 13 x > 12 or x == 0 x > 12 x 12 x == 0 x 0 0 < y < 13 0 < y 0 y 13 print("YYMM") print "YYMM" elif x > 12 or y > 12 or (x == 0 and y == 0):
    print("NA") x > 12 or y > 12 or (x == 0 and y == 0) x > 12 or y > 12 x > 12 x 12 y > 12 y 12 x == 0 and y == 0 x == 0 x 0 y == 0 y 0 print("NA") print "NA" print("AMBIGUOUS") print "AMBIGUOUS" s = input() input() s l = list(s) list(s) l x = int(l[0]+l[1]) int(l[0]+l[1]) x y = int(l[2]+l[3]) int(l[2]+l[3]) y
s = input()

l = list(s)

x = int(l[0]+l[1])
y = int(l[2]+l[3])

if 0 < x < 13 and (y > 12 or y == 0):
    print("MMYY")
elif (x > 12 or x == 0) and 0 < y < 13:
    print("YYMM")
elif x > 12 or y > 12 or (x == 0 and y == 0):
    print("NA")
else:
    print("AMBIGUOUS")