import sys

input = lambda: sys.stdin.readline().rstrip()



S = eval(input())



f = int(S[:2])

s = int(S[2:])



if (f <= 0 and s > 12) or (f > 12 and s <= 0) or (f <= 0 and s <= 0) or (f > 12 and s > 12):

    print("NA")  

elif (f > 12 and 0 < s <= 12) or (f <= 0 and 0 < s <= 12):

    print("YYMM")

elif (0 < f <= 12 and s > 12) or (0 < f <= 12 and s <= 0):

    print("MMYY")

elif 0 < f <= 12 and 0 < s <= 12:

    print("AMBIGUOUS") 
S = eval(input())



front = int(S[:2])

rear = int(S[2:])



if (front > 12 and rear > 12) or (front > 12 and rear == 0) or (rear > 12 and front == 0) or (front == 0 and rear == 0):

    print("NA")

    exit()

elif 0 < rear <= 12 and (front > 12 or front == 0):

    print("YYMM")

    exit()

elif 0 < front <= 12 and (rear > 12 or rear == 0):

    print("MMYY")

elif 0 < front <= 12 and 0 < rear <= 12:

    print("AMBIGUOUS")

import sys

input = lambda: sys.stdin.readline().rstrip()
S = eval(input())
f = int(S[:2])
s = int(S[2:])
if (
    (f <= 0 and s > 12)
    or (f > 12 and s <= 0)
    or (f <= 0 and s <= 0)
    or (f > 12 and s > 12)
):
    print("NA")
elif (f > 12 and 0 < s <= 12) or (f <= 0 and 0 < s <= 12):
    print("YYMM")
elif (0 < f <= 12 and s > 12) or (0 < f <= 12 and s <= 0):
    print("MMYY")
elif 0 < f <= 12 and 0 < s <= 12:
    print("AMBIGUOUS")

S = eval(input())
front = int(S[:2])
rear = int(S[2:])
if (
    (front > 12 and rear > 12)
    or (front > 12 and rear == 0)
    or (rear > 12 and front == 0)
    or (front == 0 and rear == 0)
):
    print("NA")
    exit()
elif 0 < rear <= 12 and (front > 12 or front == 0):
    print("YYMM")
    exit()
elif 0 < front <= 12 and (rear > 12 or rear == 0):
    print("MMYY")
elif 0 < front <= 12 and 0 < rear <= 12:
    print("AMBIGUOUS")

-import sys - -input = lambda: sys.stdin.readline().rstrip() -f = int(S[:2]) -s = int(S[2:]) +front = int(S[:2]) +rear = int(S[2:]) -    (f <= 0 and s > 12) -    or (f > 12 and s <= 0) -    or (f <= 0 and s <= 0) -    or (f > 12 and s > 12) +    (front > 12 and rear > 12) +    or (front > 12 and rear == 0) +    or (rear > 12 and front == 0) +    or (front == 0 and rear == 0) -elif (f > 12 and 0 < s <= 12) or (f <= 0 and 0 < s <= 12): +    exit() +elif 0 < rear <= 12 and (front > 12 or front == 0): -elif (0 < f <= 12 and s > 12) or (0 < f <= 12 and s <= 0): +    exit() +elif 0 < front <= 12 and (rear > 12 or rear == 0): -elif 0 < f <= 12 and 0 < s <= 12: +elif 0 < front <= 12 and 0 < rear <= 12: