S = input()
l = int(S[:2])
r = int(S[2:])
a = 0
ans = ['NA', 'MMYY', 'YYMM', 'AMBIGUOUS']
if 0 < l and l < 13:
  a += 1
if 0 < r and r < 13:
  a += 2
print(ans[a]) S = input() S input() input l = int(S[:2]) l int(S[:2]) int S[:2] S :2 2 r = int(S[2:]) r int(S[2:]) int S[2:] S 2: 2 a = 0 a 0 ans = ['NA', 'MMYY', 'YYMM', 'AMBIGUOUS'] ans ['NA', 'MMYY', 'YYMM', 'AMBIGUOUS'] 'NA' 'MMYY' 'YYMM' 'AMBIGUOUS' if 0 < l and l < 13:
  a += 1 0 < l and l < 13 0 < l 0 l l < 13 l 13 a += 1 a 1 if 0 < r and r < 13:
  a += 2 0 < r and r < 13 0 < r 0 r r < 13 r 13 a += 2 a 2 print(ans[a]) print ans[a] ans a a = 0 0 a a += 1 1 a a += 2 2 a ans = ['NA', 'MMYY', 'YYMM', 'AMBIGUOUS'] ['NA', 'MMYY', 'YYMM', 'AMBIGUOUS'] ans S = input() input() S r = int(S[2:]) int(S[2:]) r l = int(S[:2]) int(S[:2]) l
S = input()
l = int(S[:2])
r = int(S[2:])
a = 0
ans = ['NA', 'MMYY', 'YYMM', 'AMBIGUOUS']
if 0 < l and l < 13:
  a += 1
if 0 < r and r < 13:
  a += 2
print(ans[a])