def f(s):

  m,y = int(s[:2]), int(s[2:])

  return 0< m <= 12



def g(s):

  y,m = int(s[:2]), int(s[2:])

  return 0< m <= 12

    

s = input()

p,q = f(s), g(s)



if p and q:

  print('AMBIGUOUS')

elif p and not(q):

  print('MMYY')

elif q and not(p):

  print('YYMM')

else:

  print('NA')
def f(s):

  m,y = int(s[:2]), int(s[2:])

  return (0 < m <= 12,0 < y <= 12)



p,q = list(map(int,list(f(input()))))

print({(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[(p,q)])

def f(s):
    m, y = int(s[:2]), int(s[2:])
    return 0 < m <= 12


def g(s):
    y, m = int(s[:2]), int(s[2:])
    return 0 < m <= 12


s = input()
p, q = f(s), g(s)
if p and q:
    print("AMBIGUOUS")
elif p and not (q):
    print("MMYY")
elif q and not (p):
    print("YYMM")
else:
    print("NA")

def f(s):
    m, y = int(s[:2]), int(s[2:])
    return (0 < m <= 12, 0 < y <= 12)


p, q = list(map(int, list(f(input()))))
print({(0, 0): "NA", (0, 1): "YYMM", (1, 0): "MMYY", (1, 1): "AMBIGUOUS"}[(p, q)])

-    return 0 < m <= 12 +    return (0 < m <= 12, 0 < y <= 12) -def g(s): -    y, m = int(s[:2]), int(s[2:]) -    return 0 < m <= 12 - - -s = input() -p, q = f(s), g(s) -if p and q: -    print("AMBIGUOUS") -elif p and not (q): -    print("MMYY") -elif q and not (p): -    print("YYMM") -else: -    print("NA") +p, q = list(map(int, list(f(input())))) +print({(0, 0): "NA", (0, 1): "YYMM", (1, 0): "MMYY", (1, 1): "AMBIGUOUS"}[(p, q)])