def check_month(month):
    return 1 <= int(month) <= 12

S = input()

ls = S[:2]
rs = S[2:]

if check_month(ls) and check_month(rs):
    print('AMBIGUOUS')
elif check_month(ls) and not check_month(rs):
    print('MMYY')
elif not check_month(ls) and check_month(rs):
    print('YYMM')
else:
    print('NA') def check_month(month):
    return 1 <= int(month) <= 12 check_month return 1 <= int(month) <= 12 1 <= int(month) <= 12 1 <= int(month) 1 int(month) int month 12 month month S = input() S input() input ls = S[:2] ls S[:2] S :2 2 rs = S[2:] rs S[2:] S 2: 2 if check_month(ls) and check_month(rs):
    print('AMBIGUOUS')
elif check_month(ls) and not check_month(rs):
    print('MMYY')
elif not check_month(ls) and check_month(rs):
    print('YYMM')
else:
    print('NA') check_month(ls) and check_month(rs) check_month(ls) check_month ls check_month(rs) check_month rs print('AMBIGUOUS') print 'AMBIGUOUS' elif check_month(ls) and not check_month(rs):
    print('MMYY') check_month(ls) and not check_month(rs) check_month(ls) check_month ls not check_month(rs) check_month(rs) check_month rs print('MMYY') print 'MMYY' elif not check_month(ls) and check_month(rs):
    print('YYMM') not check_month(ls) and check_month(rs) not check_month(ls) check_month(ls) check_month ls check_month(rs) check_month rs print('YYMM') print 'YYMM' print('NA') print 'NA' S = input() input() S rs = S[2:] S[2:] rs def check_month(month):
    return 1 <= int(month) <= 12 def check_month(month):
    return 1 <= int(month) <= 12 check_month ls = S[:2] S[:2] ls
def check_month(month):
    return 1 <= int(month) <= 12

S = input()

ls = S[:2]
rs = S[2:]

if check_month(ls) and check_month(rs):
    print('AMBIGUOUS')
elif check_month(ls) and not check_month(rs):
    print('MMYY')
elif not check_month(ls) and check_month(rs):
    print('YYMM')
else:
    print('NA')