S = int(input())

a = int(S/100 - (S%100)/100)
b = int(S%100)

if( 0<a<13 and 0<b<13 ):
  print("AMBIGUOUS")
if( (0<a<13 and 12<b<100) or (0<a<13 and b==0) ):
  print("MMYY")
if( (12<a<100 and 0<b<13) or (a==0 and 0<b<13) ):
  print("YYMM")
if( 12<a<100 and 12<b<100 ):
  print("NA")
if( a==0 and 12<b<100 ):
  print("NA")
if( 12<a<100 and b==0 ):
  print("NA")
if( a==0 and b==0 ):
  print("NA")
 S = int(input()) S int(input()) int input() input a = int(S/100 - (S%100)/100) a int(S/100 - (S%100)/100) int S/100 - (S%100)/100 S/100 S 100 (S%100)/100 S%100 S 100 100 b = int(S%100) b int(S%100) int S%100 S 100 if( 0<a<13 and 0<b<13 ):
  print("AMBIGUOUS") 0<a<13 and 0<b<13 0<a<13 0<a 0 a 13 0<b<13 0<b 0 b 13 print("AMBIGUOUS") print "AMBIGUOUS" if( (0<a<13 and 12<b<100) or (0<a<13 and b==0) ):
  print("MMYY") (0<a<13 and 12<b<100) or (0<a<13 and b==0) 0<a<13 and 12<b<100 0<a<13 0<a 0 a 13 12<b<100 12<b 12 b 100 0<a<13 and b==0 0<a<13 0<a 0 a 13 b==0 b 0 print("MMYY") print "MMYY" if( (12<a<100 and 0<b<13) or (a==0 and 0<b<13) ):
  print("YYMM") (12<a<100 and 0<b<13) or (a==0 and 0<b<13) 12<a<100 and 0<b<13 12<a<100 12<a 12 a 100 0<b<13 0<b 0 b 13 a==0 and 0<b<13 a==0 a 0 0<b<13 0<b 0 b 13 print("YYMM") print "YYMM" if( 12<a<100 and 12<b<100 ):
  print("NA") 12<a<100 and 12<b<100 12<a<100 12<a 12 a 100 12<b<100 12<b 12 b 100 print("NA") print "NA" if( a==0 and 12<b<100 ):
  print("NA") a==0 and 12<b<100 a==0 a 0 12<b<100 12<b 12 b 100 print("NA") print "NA" if( 12<a<100 and b==0 ):
  print("NA") 12<a<100 and b==0 12<a<100 12<a 12 a 100 b==0 b 0 print("NA") print "NA" if( a==0 and b==0 ):
  print("NA") a==0 and b==0 a==0 a 0 b==0 b 0 print("NA") print "NA" S = int(input()) int(input()) S a = int(S/100 - (S%100)/100) int(S/100 - (S%100)/100) a b = int(S%100) int(S%100) b
S = int(input())

a = int(S/100 - (S%100)/100)
b = int(S%100)

if( 0<a<13 and 0<b<13 ):
  print("AMBIGUOUS")
if( (0<a<13 and 12<b<100) or (0<a<13 and b==0) ):
  print("MMYY")
if( (12<a<100 and 0<b<13) or (a==0 and 0<b<13) ):
  print("YYMM")
if( 12<a<100 and 12<b<100 ):
  print("NA")
if( a==0 and 12<b<100 ):
  print("NA")
if( 12<a<100 and b==0 ):
  print("NA")
if( a==0 and b==0 ):
  print("NA")

