s = input()
if s[0:2] in "01 02 03 04 05 06 07 08 09 10 11 12":
  l = "m"
else:
  l = "y"
if s[2:4] in "01 02 03 04 05 06 07 08 09 10 11 12":
  r = "m"
else:
  r = "y"
if l+r == "mm":
  print("AMBIGUOUS")
elif l+r == "my":
  print("MMYY")
elif l+r == "ym":
  print("YYMM")
else:
  print("NA") s = input() s input() input if s[0:2] in "01 02 03 04 05 06 07 08 09 10 11 12":
  l = "m"
else:
  l = "y" s[0:2] in "01 02 03 04 05 06 07 08 09 10 11 12" s[0:2] s 0:2 0 2 "01 02 03 04 05 06 07 08 09 10 11 12" l = "m" l "m" l = "y" l "y" if s[2:4] in "01 02 03 04 05 06 07 08 09 10 11 12":
  r = "m"
else:
  r = "y" s[2:4] in "01 02 03 04 05 06 07 08 09 10 11 12" s[2:4] s 2:4 2 4 "01 02 03 04 05 06 07 08 09 10 11 12" r = "m" r "m" r = "y" r "y" if l+r == "mm":
  print("AMBIGUOUS")
elif l+r == "my":
  print("MMYY")
elif l+r == "ym":
  print("YYMM")
else:
  print("NA") l+r == "mm" l+r l r "mm" print("AMBIGUOUS") print "AMBIGUOUS" elif l+r == "my":
  print("MMYY") l+r == "my" l+r l r "my" print("MMYY") print "MMYY" elif l+r == "ym":
  print("YYMM") l+r == "ym" l+r l r "ym" print("YYMM") print "YYMM" print("NA") print "NA" s = input() input() s l = "y" "y" l l = "m" "m" l r = "y" "y" r r = "m" "m" r
s = input()
if s[0:2] in "01 02 03 04 05 06 07 08 09 10 11 12":
  l = "m"
else:
  l = "y"
if s[2:4] in "01 02 03 04 05 06 07 08 09 10 11 12":
  r = "m"
else:
  r = "y"
if l+r == "mm":
  print("AMBIGUOUS")
elif l+r == "my":
  print("MMYY")
elif l+r == "ym":
  print("YYMM")
else:
  print("NA")