s = list(input())
a = int("".join(s[:2]))
b = int("".join(s[2:]))
c = 0
d = 0
if a and a <= 12:
    c = 1
if b and b <= 12:
    d = 1
if c and d:
    print("AMBIGUOUS")
elif c:
    print("MMYY")
elif d:
    print("YYMM")
else:
    print("NA") s = list(input()) s list(input()) list input() input a = int("".join(s[:2])) a int("".join(s[:2])) int "".join(s[:2]) "".join "" join s[:2] s :2 2 b = int("".join(s[2:])) b int("".join(s[2:])) int "".join(s[2:]) "".join "" join s[2:] s 2: 2 c = 0 c 0 d = 0 d 0 if a and a <= 12:
    c = 1 a and a <= 12 a a <= 12 a 12 c = 1 c 1 if b and b <= 12:
    d = 1 b and b <= 12 b b <= 12 b 12 d = 1 d 1 if c and d:
    print("AMBIGUOUS")
elif c:
    print("MMYY")
elif d:
    print("YYMM")
else:
    print("NA") c and d c d print("AMBIGUOUS") print "AMBIGUOUS" elif c:
    print("MMYY") c print("MMYY") print "MMYY" elif d:
    print("YYMM") d print("YYMM") print "YYMM" print("NA") print "NA" b = int("".join(s[2:])) int("".join(s[2:])) b c = 0 0 c a = int("".join(s[:2])) int("".join(s[:2])) a c = 1 1 c s = list(input()) list(input()) s d = 0 0 d d = 1 1 d
s = list(input())
a = int("".join(s[:2]))
b = int("".join(s[2:]))
c = 0
d = 0
if a and a <= 12:
    c = 1
if b and b <= 12:
    d = 1
if c and d:
    print("AMBIGUOUS")
elif c:
    print("MMYY")
elif d:
    print("YYMM")
else:
    print("NA")