S = input()

# YYMM
flag1 = False
# MMYY
flag2 = False

if 0 <= int(S[:2]) <= 99 and 1 <= int(S[2:]) <= 12:
    flag1 = True

if 1 <= int(S[:2]) <= 12 and 0 <= int(S[2:]) <= 99:
    flag2 = True

if flag1 and not flag2:
    print("YYMM")
elif not flag1 and flag2:
    print("MMYY")
elif flag1 and flag2:
    print("AMBIGUOUS")
else:
    print("NA") S = input() S input() input flag1 = False flag1 False flag2 = False flag2 False if 0 <= int(S[:2]) <= 99 and 1 <= int(S[2:]) <= 12:
    flag1 = True 0 <= int(S[:2]) <= 99 and 1 <= int(S[2:]) <= 12 0 <= int(S[:2]) <= 99 0 <= int(S[:2]) 0 int(S[:2]) int S[:2] S :2 2 99 1 <= int(S[2:]) <= 12 1 <= int(S[2:]) 1 int(S[2:]) int S[2:] S 2: 2 12 flag1 = True flag1 True if 1 <= int(S[:2]) <= 12 and 0 <= int(S[2:]) <= 99:
    flag2 = True 1 <= int(S[:2]) <= 12 and 0 <= int(S[2:]) <= 99 1 <= int(S[:2]) <= 12 1 <= int(S[:2]) 1 int(S[:2]) int S[:2] S :2 2 12 0 <= int(S[2:]) <= 99 0 <= int(S[2:]) 0 int(S[2:]) int S[2:] S 2: 2 99 flag2 = True flag2 True if flag1 and not flag2:
    print("YYMM")
elif not flag1 and flag2:
    print("MMYY")
elif flag1 and flag2:
    print("AMBIGUOUS")
else:
    print("NA") flag1 and not flag2 flag1 not flag2 flag2 print("YYMM") print "YYMM" elif not flag1 and flag2:
    print("MMYY") not flag1 and flag2 not flag1 flag1 flag2 print("MMYY") print "MMYY" elif flag1 and flag2:
    print("AMBIGUOUS") flag1 and flag2 flag1 flag2 print("AMBIGUOUS") print "AMBIGUOUS" print("NA") print "NA" S = input() input() S flag1 = True True flag1 flag2 = True True flag2 flag1 = False False flag1 flag2 = False False flag2
S = input()

# YYMM
flag1 = False
# MMYY
flag2 = False

if 0 <= int(S[:2]) <= 99 and 1 <= int(S[2:]) <= 12:
    flag1 = True

if 1 <= int(S[:2]) <= 12 and 0 <= int(S[2:]) <= 99:
    flag2 = True

if flag1 and not flag2:
    print("YYMM")
elif not flag1 and flag2:
    print("MMYY")
elif flag1 and flag2:
    print("AMBIGUOUS")
else:
    print("NA")
