s = input()
a, b = int(s[:2]), int(s[2:])
ym, my = False, False
if a > 0 and a <13:
    my = True
if b > 0 and b <13:
    ym = True
if ym and my:
    print('AMBIGUOUS')
elif ym and not my:
    print('YYMM')
elif not ym and my:
    print('MMYY')
else:
    print('NA') s = input() s input() input a, b = int(s[:2]), int(s[2:]) a int(s[:2]) int s[:2] s :2 2 b int(s[2:]) int s[2:] s 2: 2 ym, my = False, False ym False my False if a > 0 and a <13:
    my = True a > 0 and a <13 a > 0 a 0 a <13 a 13 my = True my True if b > 0 and b <13:
    ym = True b > 0 and b <13 b > 0 b 0 b <13 b 13 ym = True ym True if ym and my:
    print('AMBIGUOUS')
elif ym and not my:
    print('YYMM')
elif not ym and my:
    print('MMYY')
else:
    print('NA') ym and my ym my print('AMBIGUOUS') print 'AMBIGUOUS' elif ym and not my:
    print('YYMM') ym and not my ym not my my print('YYMM') print 'YYMM' elif not ym and my:
    print('MMYY') not ym and my not ym ym my print('MMYY') print 'MMYY' print('NA') print 'NA' my = True True my s = input() input() s ym, my = False, False False ym b = int(s[:2]), int(s[2:]) int(s[2:]) b ym = True True ym a, b = int(s[:2]), int(s[2:]) int(s[:2]) a my = False, False False my
s = input()
a, b = int(s[:2]), int(s[2:])
ym, my = False, False
if a > 0 and a <13:
    my = True
if b > 0 and b <13:
    ym = True
if ym and my:
    print('AMBIGUOUS')
elif ym and not my:
    print('YYMM')
elif not ym and my:
    print('MMYY')
else:
    print('NA')