s = input()

i1 = int(s[:2])
i2 = int(s[2:])



def f(i):
    if (0 < i < 13):
        return 1
    elif (0 < i < 100):
        return 2
    else:
        return 0


f1 = f(i1)
f2 = f(i2)

if (f1 == 1):
    if (f2 == 1):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if (f2 == 1):
        print("YYMM")
    else:
        print("NA")

 s = input() s input() input i1 = int(s[:2]) i1 int(s[:2]) int s[:2] s :2 2 i2 = int(s[2:]) i2 int(s[2:]) int s[2:] s 2: 2 def f(i):
    if (0 < i < 13):
        return 1
    elif (0 < i < 100):
        return 2
    else:
        return 0 f if (0 < i < 13):
        return 1
    elif (0 < i < 100):
        return 2
    else:
        return 0 0 < i < 13 0 < i 0 i 13 return 1 1 elif (0 < i < 100):
        return 2
     0 < i < 100 0 < i 0 i 100 return 2 2 return 0 0 i i f1 = f(i1) f1 f(i1) f i1 f2 = f(i2) f2 f(i2) f i2 if (f1 == 1):
    if (f2 == 1):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if (f2 == 1):
        print("YYMM")
    else:
        print("NA") f1 == 1 f1 1 if (f2 == 1):
        print("AMBIGUOUS")
    else:
        print("MMYY") f2 == 1 f2 1 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if (f2 == 1):
        print("YYMM")
    else:
        print("NA") f2 == 1 f2 1 print("YYMM") print "YYMM" print("NA") print "NA" i1 = int(s[:2]) int(s[:2]) i1 f2 = f(i2) f(i2) f2 def f(i):
    if (0 < i < 13):
        return 1
    elif (0 < i < 100):
        return 2
    else:
        return 0 def f(i):
    if (0 < i < 13):
        return 1
    elif (0 < i < 100):
        return 2
    else:
        return 0 f i2 = int(s[2:]) int(s[2:]) i2 s = input() input() s f1 = f(i1) f(i1) f1
s = input()

i1 = int(s[:2])
i2 = int(s[2:])



def f(i):
    if (0 < i < 13):
        return 1
    elif (0 < i < 100):
        return 2
    else:
        return 0


f1 = f(i1)
f2 = f(i2)

if (f1 == 1):
    if (f2 == 1):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if (f2 == 1):
        print("YYMM")
    else:
        print("NA")


