S = input()
f = int(S[0]+S[1])
b = int(S[2]+S[3])

def judge(int):
    if 1 <= int <= 12:
        return 0
    else:
        return 1
ref = [judge(f), judge(b)]

if ref == [1, 1]:
    print("NA")
elif ref == [0, 1]:
    print("MMYY")
elif ref == [1, 0]:
    print("YYMM")
else:
    print("AMBIGUOUS") S = input() S input() input f = int(S[0]+S[1]) f int(S[0]+S[1]) int S[0]+S[1] S[0] S 0 S[1] S 1 b = int(S[2]+S[3]) b int(S[2]+S[3]) int S[2]+S[3] S[2] S 2 S[3] S 3 def judge(int):
    if 1 <= int <= 12:
        return 0
    else:
        return 1 judge if 1 <= int <= 12:
        return 0
    else:
        return 1 1 <= int <= 12 1 <= int 1 int 12 return 0 0 return 1 1 int int ref = [judge(f), judge(b)] ref [judge(f), judge(b)] judge(f) judge f judge(b) judge b if ref == [1, 1]:
    print("NA")
elif ref == [0, 1]:
    print("MMYY")
elif ref == [1, 0]:
    print("YYMM")
else:
    print("AMBIGUOUS") ref == [1, 1] ref [1, 1] 1 1 print("NA") print "NA" elif ref == [0, 1]:
    print("MMYY") ref == [0, 1] ref [0, 1] 0 1 print("MMYY") print "MMYY" elif ref == [1, 0]:
    print("YYMM") ref == [1, 0] ref [1, 0] 1 0 print("YYMM") print "YYMM" print("AMBIGUOUS") print "AMBIGUOUS" S = input() input() S ref = [judge(f), judge(b)] [judge(f), judge(b)] ref def judge(int):
    if 1 <= int <= 12:
        return 0
    else:
        return 1 def judge(int):
    if 1 <= int <= 12:
        return 0
    else:
        return 1 judge f = int(S[0]+S[1]) int(S[0]+S[1]) f b = int(S[2]+S[3]) int(S[2]+S[3]) b
S = input()
f = int(S[0]+S[1])
b = int(S[2]+S[3])

def judge(int):
    if 1 <= int <= 12:
        return 0
    else:
        return 1
ref = [judge(f), judge(b)]

if ref == [1, 1]:
    print("NA")
elif ref == [0, 1]:
    print("MMYY")
elif ref == [1, 0]:
    print("YYMM")
else:
    print("AMBIGUOUS")
