S = int(eval(input()))



L = S // 100 # 前半2桁

R = S % 100 # 後半2桁



if L > 12 or L == 0:

  if R > 12 or R == 0: print('NA')

  else: print('YYMM')

else:

  if R > 12 or R == 0: print('MMYY')

  else: print('AMBIGUOUS')
S = int(eval(input()))

 

L = S // 100 # 前半2桁

R = S % 100 # 後半2桁

 

if 1 <= L <= 12:

  if 1 <= R <= 12: print('AMBIGUOUS')

  else: print('MMYY')

else:

  if 1 <= R <= 12: print('YYMM')

  else: print('NA')
S = int(eval(input()))
L = S // 100  # 前半2桁
R = S % 100  # 後半2桁
if L > 12 or L == 0:
    if R > 12 or R == 0:
        print("NA")
    else:
        print("YYMM")
else:
    if R > 12 or R == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")

S = int(eval(input()))
L = S // 100  # 前半2桁
R = S % 100  # 後半2桁
if 1 <= L <= 12:
    if 1 <= R <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= R <= 12:
        print("YYMM")
    else:
        print("NA")

-if L > 12 or L == 0: -    if R > 12 or R == 0: +if 1 <= L <= 12: +    if 1 <= R <= 12: +        print("AMBIGUOUS") +    else: +        print("MMYY") +else: +    if 1 <= R <= 12: +        print("YYMM") +    else: -    else: -        print("YYMM") -else: -    if R > 12 or R == 0: -        print("MMYY") -    else: -        print("AMBIGUOUS")