N=list(eval(input()))

A=int(''.join(N[0:2]))

B=int(''.join(N[2:4]))



FLG_A = (A>12) or A==0

FLG_B = (B>12) or B==0





if FLG_A & FLG_B:

    ans='NA'

elif FLG_A & ~FLG_B:

    ans='YYMM'

elif ~FLG_A & FLG_B:

    ans='MMYY'

elif ~FLG_A & ~FLG_B:

    ans='AMBIGUOUS'



print(ans)
N=list(eval(input()))

A=int(''.join(N[0:2]))

B=int(''.join(N[2:4]))



FLG_A = (A>12) | (A==0)

FLG_B = (B>12) | (B==0)





if FLG_A & FLG_B:

    ans='NA'

elif FLG_A & ~FLG_B:

    ans='YYMM'

elif ~FLG_A & FLG_B:

    ans='MMYY'

elif ~FLG_A & ~FLG_B:

    ans='AMBIGUOUS'



print(ans)
N = list(eval(input()))
A = int("".join(N[0:2]))
B = int("".join(N[2:4]))
FLG_A = (A > 12) or A == 0
FLG_B = (B > 12) or B == 0
if FLG_A & FLG_B:
    ans = "NA"
elif FLG_A & ~FLG_B:
    ans = "YYMM"
elif ~FLG_A & FLG_B:
    ans = "MMYY"
elif ~FLG_A & ~FLG_B:
    ans = "AMBIGUOUS"
print(ans)

N = list(eval(input()))
A = int("".join(N[0:2]))
B = int("".join(N[2:4]))
FLG_A = (A > 12) | (A == 0)
FLG_B = (B > 12) | (B == 0)
if FLG_A & FLG_B:
    ans = "NA"
elif FLG_A & ~FLG_B:
    ans = "YYMM"
elif ~FLG_A & FLG_B:
    ans = "MMYY"
elif ~FLG_A & ~FLG_B:
    ans = "AMBIGUOUS"
print(ans)

-FLG_A = (A > 12) or A == 0 -FLG_B = (B > 12) or B == 0 +FLG_A = (A > 12) | (A == 0) +FLG_B = (B > 12) | (B == 0)