S = input()

heads = int(S[:2])
tails = int(S[2:])


def is_month(n):
    return n >= 1 and n <= 12


if is_month(heads) and (not is_month(tails)):
    print("MMYY")
elif (not is_month(heads)) and (not is_month(tails)):
    print("NA")
elif (not is_month(heads)) and is_month(tails):
    print("YYMM")
else:
    print("AMBIGUOUS") S = input() S input() input heads = int(S[:2]) heads int(S[:2]) int S[:2] S :2 2 tails = int(S[2:]) tails int(S[2:]) int S[2:] S 2: 2 def is_month(n):
    return n >= 1 and n <= 12 is_month return n >= 1 and n <= 12 n >= 1 and n <= 12 n >= 1 n 1 n <= 12 n 12 n n if is_month(heads) and (not is_month(tails)):
    print("MMYY")
elif (not is_month(heads)) and (not is_month(tails)):
    print("NA")
elif (not is_month(heads)) and is_month(tails):
    print("YYMM")
else:
    print("AMBIGUOUS") is_month(heads) and (not is_month(tails)) is_month(heads) is_month heads not is_month(tails) is_month(tails) is_month tails print("MMYY") print "MMYY" elif (not is_month(heads)) and (not is_month(tails)):
    print("NA") (not is_month(heads)) and (not is_month(tails)) not is_month(heads) is_month(heads) is_month heads not is_month(tails) is_month(tails) is_month tails print("NA") print "NA" elif (not is_month(heads)) and is_month(tails):
    print("YYMM") (not is_month(heads)) and is_month(tails) not is_month(heads) is_month(heads) is_month heads is_month(tails) is_month tails print("YYMM") print "YYMM" print("AMBIGUOUS") print "AMBIGUOUS" S = input() input() S def is_month(n):
    return n >= 1 and n <= 12 def is_month(n):
    return n >= 1 and n <= 12 is_month tails = int(S[2:]) int(S[2:]) tails heads = int(S[:2]) int(S[:2]) heads
S = input()

heads = int(S[:2])
tails = int(S[2:])


def is_month(n):
    return n >= 1 and n <= 12


if is_month(heads) and (not is_month(tails)):
    print("MMYY")
elif (not is_month(heads)) and (not is_month(tails)):
    print("NA")
elif (not is_month(heads)) and is_month(tails):
    print("YYMM")
else:
    print("AMBIGUOUS")
