def check_my(string):
    if 1 <= int(string) <= 12:
        return 'YorM'
    else:
        return 'Y'

s = input()
my_set = (check_my(s[0:2]), check_my(s[2:4]))
if my_set == ('YorM', 'YorM'):
    print('AMBIGUOUS')
elif my_set == ('YorM', 'Y'):
    print('MMYY')
elif my_set == ('Y', 'YorM'):
    print('YYMM')
else:
    print('NA') def check_my(string):
    if 1 <= int(string) <= 12:
        return 'YorM'
    else:
        return 'Y' check_my if 1 <= int(string) <= 12:
        return 'YorM'
    else:
        return 'Y' 1 <= int(string) <= 12 1 <= int(string) 1 int(string) int string 12 return 'YorM' 'YorM' return 'Y' 'Y' string string s = input() s input() input my_set = (check_my(s[0:2]), check_my(s[2:4])) my_set (check_my(s[0:2]), check_my(s[2:4])) check_my(s[0:2]) check_my s[0:2] s 0:2 0 2 check_my(s[2:4]) check_my s[2:4] s 2:4 2 4 if my_set == ('YorM', 'YorM'):
    print('AMBIGUOUS')
elif my_set == ('YorM', 'Y'):
    print('MMYY')
elif my_set == ('Y', 'YorM'):
    print('YYMM')
else:
    print('NA') my_set == ('YorM', 'YorM') my_set ('YorM', 'YorM') 'YorM' 'YorM' print('AMBIGUOUS') print 'AMBIGUOUS' elif my_set == ('YorM', 'Y'):
    print('MMYY') my_set == ('YorM', 'Y') my_set ('YorM', 'Y') 'YorM' 'Y' print('MMYY') print 'MMYY' elif my_set == ('Y', 'YorM'):
    print('YYMM') my_set == ('Y', 'YorM') my_set ('Y', 'YorM') 'Y' 'YorM' print('YYMM') print 'YYMM' print('NA') print 'NA' def check_my(string):
    if 1 <= int(string) <= 12:
        return 'YorM'
    else:
        return 'Y' def check_my(string):
    if 1 <= int(string) <= 12:
        return 'YorM'
    else:
        return 'Y' check_my s = input() input() s my_set = (check_my(s[0:2]), check_my(s[2:4])) (check_my(s[0:2]), check_my(s[2:4])) my_set
def check_my(string):
    if 1 <= int(string) <= 12:
        return 'YorM'
    else:
        return 'Y'

s = input()
my_set = (check_my(s[0:2]), check_my(s[2:4]))
if my_set == ('YorM', 'YorM'):
    print('AMBIGUOUS')
elif my_set == ('YorM', 'Y'):
    print('MMYY')
elif my_set == ('Y', 'YorM'):
    print('YYMM')
else:
    print('NA')
