s=input()

def month(n):
    if 1 <= n <= 12:
        return True
    else:
        return False


if int(s[0:2]) == 0:
    if month(int(s[2:4])) :
        print("YYMM")
        exit()
    else:
        print("NA")
        exit()

if int(s[2:4]) == 0:
    if month(int(s[0:2])):
        print("MMYY")
        exit()
    else:
        print("NA")
        exit()


if month(int(s[0:2])):
    if month(int(s[2:4])):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if month(int(s[2:4])):
            print("YYMM")
    else:
        print("NA") s=input() s input() input def month(n):
    if 1 <= n <= 12:
        return True
    else:
        return False month if 1 <= n <= 12:
        return True
    else:
        return False 1 <= n <= 12 1 <= n 1 n 12 return True True return False False n n if int(s[0:2]) == 0:
    if month(int(s[2:4])) :
        print("YYMM")
        exit()
    else:
        print("NA")
        exit() int(s[0:2]) == 0 int(s[0:2]) int s[0:2] s 0:2 0 2 0 if month(int(s[2:4])) :
        print("YYMM")
        exit()
    else:
        print("NA")
        exit() month(int(s[2:4])) month int(s[2:4]) int s[2:4] s 2:4 2 4 print("YYMM") print "YYMM" exit() exit print("NA") print "NA" exit() exit if int(s[2:4]) == 0:
    if month(int(s[0:2])):
        print("MMYY")
        exit()
    else:
        print("NA")
        exit() int(s[2:4]) == 0 int(s[2:4]) int s[2:4] s 2:4 2 4 0 if month(int(s[0:2])):
        print("MMYY")
        exit()
    else:
        print("NA")
        exit() month(int(s[0:2])) month int(s[0:2]) int s[0:2] s 0:2 0 2 print("MMYY") print "MMYY" exit() exit print("NA") print "NA" exit() exit if month(int(s[0:2])):
    if month(int(s[2:4])):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if month(int(s[2:4])):
            print("YYMM")
    else:
        print("NA") month(int(s[0:2])) month int(s[0:2]) int s[0:2] s 0:2 0 2 if month(int(s[2:4])):
        print("AMBIGUOUS")
    else:
        print("MMYY") month(int(s[2:4])) month int(s[2:4]) int s[2:4] s 2:4 2 4 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if month(int(s[2:4])):
            print("YYMM")
    else:
        print("NA") month(int(s[2:4])) month int(s[2:4]) int s[2:4] s 2:4 2 4 print("YYMM") print "YYMM" print("NA") print "NA" def month(n):
    if 1 <= n <= 12:
        return True
    else:
        return False def month(n):
    if 1 <= n <= 12:
        return True
    else:
        return False month s=input() input() s
s=input()

def month(n):
    if 1 <= n <= 12:
        return True
    else:
        return False


if int(s[0:2]) == 0:
    if month(int(s[2:4])) :
        print("YYMM")
        exit()
    else:
        print("NA")
        exit()

if int(s[2:4]) == 0:
    if month(int(s[0:2])):
        print("MMYY")
        exit()
    else:
        print("NA")
        exit()


if month(int(s[0:2])):
    if month(int(s[2:4])):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if month(int(s[2:4])):
            print("YYMM")
    else:
        print("NA")
