s = input()
def YYMM(s):
    p = int(s[2:])
    if 1 <= p <= 12:
        return True
    return False

def MMYY(s):
    p = int(s[:2])
    if 1 <= p <= 12:
        return True 
    return False

if YYMM(s) and MMYY(s):
    print('AMBIGUOUS')
elif YYMM(s):
    print('YYMM')
elif MMYY(s):
    print('MMYY')
else:
    print('NA') s = input() s input() input def YYMM(s):
    p = int(s[2:])
    if 1 <= p <= 12:
        return True
    return False YYMM p = int(s[2:]) p int(s[2:]) int s[2:] s 2: 2 if 1 <= p <= 12:
        return True
     1 <= p <= 12 1 <= p 1 p 12 return True True return False False s s def MMYY(s):
    p = int(s[:2])
    if 1 <= p <= 12:
        return True 
    return False MMYY p = int(s[:2]) p int(s[:2]) int s[:2] s :2 2 if 1 <= p <= 12:
        return True 
     1 <= p <= 12 1 <= p 1 p 12 return True True return False False s s if YYMM(s) and MMYY(s):
    print('AMBIGUOUS')
elif YYMM(s):
    print('YYMM')
elif MMYY(s):
    print('MMYY')
else:
    print('NA') YYMM(s) and MMYY(s) YYMM(s) YYMM s MMYY(s) MMYY s print('AMBIGUOUS') print 'AMBIGUOUS' elif YYMM(s):
    print('YYMM') YYMM(s) YYMM s print('YYMM') print 'YYMM' elif MMYY(s):
    print('MMYY') MMYY(s) MMYY s print('MMYY') print 'MMYY' print('NA') print 'NA' def YYMM(s):
    p = int(s[2:])
    if 1 <= p <= 12:
        return True
    return False def YYMM(s):
    p = int(s[2:])
    if 1 <= p <= 12:
        return True
    return False YYMM def MMYY(s):
    p = int(s[:2])
    if 1 <= p <= 12:
        return True 
    return False def MMYY(s):
    p = int(s[:2])
    if 1 <= p <= 12:
        return True 
    return False MMYY s = input() input() s
s = input()
def YYMM(s):
    p = int(s[2:])
    if 1 <= p <= 12:
        return True
    return False

def MMYY(s):
    p = int(s[:2])
    if 1 <= p <= 12:
        return True 
    return False

if YYMM(s) and MMYY(s):
    print('AMBIGUOUS')
elif YYMM(s):
    print('YYMM')
elif MMYY(s):
    print('MMYY')
else:
    print('NA')