S = input()
l, r =  map(int, [S[:2], S[2:]])

if 1 <= l <= 12 and 1 <= r <= 12:
  print("AMBIGUOUS")
elif 1 <= l <= 12 and (r == 0 or r > 12):
  print("MMYY")
elif (l == 0 or l > 12) and 1 <= r <= 12:
  print("YYMM")
else:
  print("NA") S = input() S input() input l, r =  map(int, [S[:2], S[2:]]) l map(int, [S[:2], S[2:]]) map int [S[:2], S[2:]] S[:2] S :2 2 S[2:] S 2: 2 r if 1 <= l <= 12 and 1 <= r <= 12:
  print("AMBIGUOUS")
elif 1 <= l <= 12 and (r == 0 or r > 12):
  print("MMYY")
elif (l == 0 or l > 12) and 1 <= r <= 12:
  print("YYMM")
else:
  print("NA") 1 <= l <= 12 and 1 <= r <= 12 1 <= l <= 12 1 <= l 1 l 12 1 <= r <= 12 1 <= r 1 r 12 print("AMBIGUOUS") print "AMBIGUOUS" elif 1 <= l <= 12 and (r == 0 or r > 12):
  print("MMYY") 1 <= l <= 12 and (r == 0 or r > 12) 1 <= l <= 12 1 <= l 1 l 12 r == 0 or r > 12 r == 0 r 0 r > 12 r 12 print("MMYY") print "MMYY" elif (l == 0 or l > 12) and 1 <= r <= 12:
  print("YYMM") (l == 0 or l > 12) and 1 <= r <= 12 l == 0 or l > 12 l == 0 l 0 l > 12 l 12 1 <= r <= 12 1 <= r 1 r 12 print("YYMM") print "YYMM" print("NA") print "NA" l, r =  map(int, [S[:2], S[2:]]) map(int, [S[:2], S[2:]]) l S = input() input() S r =  map(int, [S[:2], S[2:]]) map(int, [S[:2], S[2:]]) r
S = input()
l, r =  map(int, [S[:2], S[2:]])

if 1 <= l <= 12 and 1 <= r <= 12:
  print("AMBIGUOUS")
elif 1 <= l <= 12 and (r == 0 or r > 12):
  print("MMYY")
elif (l == 0 or l > 12) and 1 <= r <= 12:
  print("YYMM")
else:
  print("NA")