s=input()
flag1=0
flag2=0
if 0<int(s[:2])<13:
  flag1=1
else:
  pass
if 0<int(s[2:])<13:
  flag2=1
else:
  pass

if flag1==0 and flag2==0:
  print("NA")
elif flag1==1 and flag2==0:
  print("MMYY")
elif flag1==0 and flag2==1:
  print("YYMM")
else:
  print("AMBIGUOUS") s=input() s input() input flag1=0 flag1 0 flag2=0 flag2 0 if 0<int(s[:2])<13:
  flag1=1
else:
  pass 0<int(s[:2])<13 0<int(s[:2]) 0 int(s[:2]) int s[:2] s :2 2 13 flag1=1 flag1 1 if 0<int(s[2:])<13:
  flag2=1
else:
  pass 0<int(s[2:])<13 0<int(s[2:]) 0 int(s[2:]) int s[2:] s 2: 2 13 flag2=1 flag2 1 if flag1==0 and flag2==0:
  print("NA")
elif flag1==1 and flag2==0:
  print("MMYY")
elif flag1==0 and flag2==1:
  print("YYMM")
else:
  print("AMBIGUOUS") flag1==0 and flag2==0 flag1==0 flag1 0 flag2==0 flag2 0 print("NA") print "NA" elif flag1==1 and flag2==0:
  print("MMYY") flag1==1 and flag2==0 flag1==1 flag1 1 flag2==0 flag2 0 print("MMYY") print "MMYY" elif flag1==0 and flag2==1:
  print("YYMM") flag1==0 and flag2==1 flag1==0 flag1 0 flag2==1 flag2 1 print("YYMM") print "YYMM" print("AMBIGUOUS") print "AMBIGUOUS" flag2=0 0 flag2 flag1=1 1 flag1 s=input() input() s flag2=1 1 flag2 flag1=0 0 flag1
s=input()
flag1=0
flag2=0
if 0<int(s[:2])<13:
  flag1=1
else:
  pass
if 0<int(s[2:])<13:
  flag2=1
else:
  pass

if flag1==0 and flag2==0:
  print("NA")
elif flag1==1 and flag2==0:
  print("MMYY")
elif flag1==0 and flag2==1:
  print("YYMM")
else:
  print("AMBIGUOUS")