def main():
    S = str(input())
    front = int(S[0:2])
    latter = int(S[2:4])
    if front < 13 and latter < 13 and (front > 0 and latter > 0):
        print('AMBIGUOUS')
    elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
    elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
    else:
        print('NA')
main() def main():
    S = str(input())
    front = int(S[0:2])
    latter = int(S[2:4])
    if front < 13 and latter < 13 and (front > 0 and latter > 0):
        print('AMBIGUOUS')
    elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
    elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
    else:
        print('NA') main S = str(input()) S str(input()) str input() input front = int(S[0:2]) front int(S[0:2]) int S[0:2] S 0:2 0 2 latter = int(S[2:4]) latter int(S[2:4]) int S[2:4] S 2:4 2 4 if front < 13 and latter < 13 and (front > 0 and latter > 0):
        print('AMBIGUOUS')
    elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
    elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
    else:
        print('NA') front < 13 and latter < 13 and (front > 0 and latter > 0) front < 13 and latter < 13 front < 13 front 13 latter < 13 latter 13 front > 0 and latter > 0 front > 0 front 0 latter > 0 latter 0 print('AMBIGUOUS') print 'AMBIGUOUS' elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
     front < 13 and latter < 100 and front > 0 front < 13 and latter < 100 front < 13 front 13 latter < 100 latter 100 front > 0 front 0 print('MMYY') print 'MMYY' elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
     front < 100 and latter < 13 and latter > 0 front < 100 and latter < 13 front < 100 front 100 latter < 13 latter 13 latter > 0 latter 0 print('YYMM') print 'YYMM' print('NA') print 'NA' main() main def main():
    S = str(input())
    front = int(S[0:2])
    latter = int(S[2:4])
    if front < 13 and latter < 13 and (front > 0 and latter > 0):
        print('AMBIGUOUS')
    elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
    elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
    else:
        print('NA') def main():
    S = str(input())
    front = int(S[0:2])
    latter = int(S[2:4])
    if front < 13 and latter < 13 and (front > 0 and latter > 0):
        print('AMBIGUOUS')
    elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
    elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
    else:
        print('NA') main
def main():
    S = str(input())
    front = int(S[0:2])
    latter = int(S[2:4])
    if front < 13 and latter < 13 and (front > 0 and latter > 0):
        print('AMBIGUOUS')
    elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
    elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
    else:
        print('NA')
main()