s = input()
a = s[0] + s[1]
b = s[2] + s[3]
p = 0
q = 0
if a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" or a == "08" or a == "09" or a == "10" or a == "11" or a == "12":
    p = 1
if b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" or b == "08" or b == "09" or b == "10" or b == "11" or b == "12":
    q = 1  
if p == 1 and q == 1:
    print("AMBIGUOUS")
elif p == 1 and q == 0:
    print("MMYY")
elif p == 0 and q == 1:
    print("YYMM")
else:
    print("NA") s = input() s input() input a = s[0] + s[1] a s[0] + s[1] s[0] s 0 s[1] s 1 b = s[2] + s[3] b s[2] + s[3] s[2] s 2 s[3] s 3 p = 0 p 0 q = 0 q 0 if a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" or a == "08" or a == "09" or a == "10" or a == "11" or a == "12":
    p = 1 a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" or a == "08" or a == "09" or a == "10" or a == "11" or a == "12" a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" or a == "08" or a == "09" or a == "10" or a == "11" a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" or a == "08" or a == "09" or a == "10" a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" or a == "08" or a == "09" a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" or a == "08" a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" a == "01" or a == "02" or a == "03" or a == "04" or a == "05" a == "01" or a == "02" or a == "03" or a == "04" a == "01" or a == "02" or a == "03" a == "01" or a == "02" a == "01" a "01" a == "02" a "02" a == "03" a "03" a == "04" a "04" a == "05" a "05" a == "06" a "06" a == "07" a "07" a == "08" a "08" a == "09" a "09" a == "10" a "10" a == "11" a "11" a == "12" a "12" p = 1 p 1 if b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" or b == "08" or b == "09" or b == "10" or b == "11" or b == "12":
    q = 1   b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" or b == "08" or b == "09" or b == "10" or b == "11" or b == "12" b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" or b == "08" or b == "09" or b == "10" or b == "11" b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" or b == "08" or b == "09" or b == "10" b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" or b == "08" or b == "09" b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" or b == "08" b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" b == "01" or b == "02" or b == "03" or b == "04" or b == "05" b == "01" or b == "02" or b == "03" or b == "04" b == "01" or b == "02" or b == "03" b == "01" or b == "02" b == "01" b "01" b == "02" b "02" b == "03" b "03" b == "04" b "04" b == "05" b "05" b == "06" b "06" b == "07" b "07" b == "08" b "08" b == "09" b "09" b == "10" b "10" b == "11" b "11" b == "12" b "12" q = 1 q 1 if p == 1 and q == 1:
    print("AMBIGUOUS")
elif p == 1 and q == 0:
    print("MMYY")
elif p == 0 and q == 1:
    print("YYMM")
else:
    print("NA") p == 1 and q == 1 p == 1 p 1 q == 1 q 1 print("AMBIGUOUS") print "AMBIGUOUS" elif p == 1 and q == 0:
    print("MMYY") p == 1 and q == 0 p == 1 p 1 q == 0 q 0 print("MMYY") print "MMYY" elif p == 0 and q == 1:
    print("YYMM") p == 0 and q == 1 p == 0 p 0 q == 1 q 1 print("YYMM") print "YYMM" print("NA") print "NA" s = input() input() s a = s[0] + s[1] s[0] + s[1] a q = 0 0 q q = 1 1 q p = 0 0 p p = 1 1 p b = s[2] + s[3] s[2] + s[3] b
s = input()
a = s[0] + s[1]
b = s[2] + s[3]
p = 0
q = 0
if a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" or a == "08" or a == "09" or a == "10" or a == "11" or a == "12":
    p = 1
if b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" or b == "08" or b == "09" or b == "10" or b == "11" or b == "12":
    q = 1  
if p == 1 and q == 1:
    print("AMBIGUOUS")
elif p == 1 and q == 0:
    print("MMYY")
elif p == 0 and q == 1:
    print("YYMM")
else:
    print("NA")