s = eval(input())

s1 = s[:2]

s2 = s[2:]



if 1 <=int(s1) <= 12:

    if 1 <= int(s2) <= 12:

        print('AMBIGUOUS')

    else:

        print('MMYY')

else:

    if 1 <= int(s2) <= 12:

        print('YYMM')

    else:

        print('NA')
s = eval(input())



if 1 <= int(s[:2]) <= 12:

    if 1 <= int(s[2:]) <= 12:

        print('AMBIGUOUS')

    else:

        print('MMYY')

else:

    if 1 <= int(s[2:]) <= 12:

        print('YYMM')

    else:

        print('NA')
s = eval(input())
s1 = s[:2]
s2 = s[2:]
if 1 <= int(s1) <= 12:
    if 1 <= int(s2) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= int(s2) <= 12:
        print("YYMM")
    else:
        print("NA")

s = eval(input())
if 1 <= int(s[:2]) <= 12:
    if 1 <= int(s[2:]) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= int(s[2:]) <= 12:
        print("YYMM")
    else:
        print("NA")

-s1 = s[:2] -s2 = s[2:] -if 1 <= int(s1) <= 12: -    if 1 <= int(s2) <= 12: +if 1 <= int(s[:2]) <= 12: +    if 1 <= int(s[2:]) <= 12: -    if 1 <= int(s2) <= 12: +    if 1 <= int(s[2:]) <= 12: