S = 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") S = input() S input() input front = int(S[:2]) front int(S[:2]) int S[:2] S :2 2 rear = int(S[2:]) rear int(S[2:]) int S[2:] S 2: 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") (front > 12 and rear > 12) or (front > 12 and rear == 0) or (rear > 12 and front == 0) or (front == 0 and rear == 0) (front > 12 and rear > 12) or (front > 12 and rear == 0) or (rear > 12 and front == 0) (front > 12 and rear > 12) or (front > 12 and rear == 0) front > 12 and rear > 12 front > 12 front 12 rear > 12 rear 12 front > 12 and rear == 0 front > 12 front 12 rear == 0 rear 0 rear > 12 and front == 0 rear > 12 rear 12 front == 0 front 0 front == 0 and rear == 0 front == 0 front 0 rear == 0 rear 0 print("NA") print "NA" exit() exit elif 0 < rear <= 12 and (front > 12 or front == 0):
    print("YYMM")
    exit() 0 < rear <= 12 and (front > 12 or front == 0) 0 < rear <= 12 0 < rear 0 rear 12 front > 12 or front == 0 front > 12 front 12 front == 0 front 0 print("YYMM") print "YYMM" exit() exit elif 0 < front <= 12 and (rear > 12 or rear == 0):
    print("MMYY") 0 < front <= 12 and (rear > 12 or rear == 0) 0 < front <= 12 0 < front 0 front 12 rear > 12 or rear == 0 rear > 12 rear 12 rear == 0 rear 0 print("MMYY") print "MMYY" elif 0 < front <= 12 and 0 < rear <= 12:
    print("AMBIGUOUS") 0 < front <= 12 and 0 < rear <= 12 0 < front <= 12 0 < front 0 front 12 0 < rear <= 12 0 < rear 0 rear 12 print("AMBIGUOUS") print "AMBIGUOUS" rear = int(S[2:]) int(S[2:]) rear S = input() input() S front = int(S[:2]) int(S[:2]) front
S = 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")
