peterverebics/CodeNet_Python_118 huggingface dataset:
S = int(input())
A = S//100
B = S%100
if 0 < A <= 12 and 0 < B <= 12:
    print("AMBIGUOUS")
elif 0 < A <= 12:
    print("MMYY")
elif 0 < B <= 12:
    print("YYMM")
else:
    print("NA")
s = str(input())
a, b = int(s[:2]), int(s[2:])

if 1 <= a <= 12:
    print('AMBIGUOUS' if 1 <= b <= 12 else 'MMYY')
else:
    print('YYMM' if 1 <= b <= 12 else 'NA')
#B
s = input()
# print(int(s[0:2]), int(s[2:4]))
if 1 <= int(s[0:2]) <= 12 and 1 <= int(s[2:4]) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(s[0:2]) <= 12:
    print('MMYY')
elif 1 <= int(s[2:4]) <= 12:
    print('YYMM')
else:
    print('NA')
s = str (input())
bflag = True
lflag = True
if not(s[0] + s[1] in ['01','02','03','04','05','06','07','08','09','10','11','12']):
    bflag = False
if not(s[2] + s[3] in ['01','02','03','04','05','06','07','08','09','10','11','12']):
    lflag = False
if bflag:
    if lflag:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if lflag:
        print('YYMM')
    else:
        print('NA')
s=input()
YY=["00"]
MM=["01","02","03","04","05","06","07","08","09","10","11","12"]

for i in range(13,100):
    YY.append(str(i))

if s[:2] in YY and s[2:] in MM:
    print("YYMM")
elif s[:2] in MM and s[2:] in YY:
    print("MMYY")
elif s[:2] in MM and s[2:] in MM:
    print("AMBIGUOUS")
else:
    print("NA")
S = input()
first = int(S[:2])
last = int(S[2:])

is_month_first = False
is_month_last = False

if first <= 12 and first > 0:
    is_month_first = True
if last <= 12 and last > 0:
    is_month_last = True

if is_month_first and is_month_last:
    print("AMBIGUOUS")
elif not is_month_first and not is_month_last:
    print("NA")
else:
    if is_month_first:
        print("MMYY")
    else:
        print("YYMM")
s = input()
before = int(s[:2])
after = int(s[2:])
if 1 <= before <= 12:
  if 1 <= after <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= after <= 12:
    print('YYMM')
  else:
    print('NA')
s=input()
t,u=0<int(s[:2])<13,0<int(s[2:])<13
print('AMBIGUOUS' if t and u else 'MMYY' if t else 'YYMM' if u else 'NA')
s = input()
a = int(s[:2])
b = int(s[2:])
yymm = 1<=b<=12
mmyy = 1<=a<=12
if yymm:
  if mmyy:
    print("AMBIGUOUS")
  else:
    print("YYMM")
else:
  if mmyy:
    print("MMYY")
  else:
    print("NA")
s = input()
a = int(s[:2])
b = int(s[-2:])
ym = True if 1 <= b <= 12 else False
my = True if 1 <= a <= 12 else False
print('AMBIGUOUS' if ym and my else 'YYMM' if ym else 'MMYY' if my else 'NA')
S = list(input())

S1 = int(S[0]+S[1])
S2 = int(S[2]+S[3])

if((S1 == 0 and S2 == 0) or (S1 > 12 and S2 > 12)):
    print('NA')
elif(S1 == 0 or S2 ==0):
    if(S1 < 13 and S1 > 0):
        print('MMYY')
    elif(S2 < 13 and S2 > 0):
        print('YYMM')
    else:
        print('NA')
elif(S1 < 13 and S2 < 13):
    print('AMBIGUOUS')
elif(S1 < 13 and S1 > 0):
    print('MMYY')
elif(S2 < 13 and S2 > 0):
    print('YYMM')
s = int(input())
b = s%100
a = (s - b)//100
if (0 < a <= 12 and 0 < b <= 12):
    print("AMBIGUOUS")
elif (0 < a <= 12):
    print("MMYY")
elif (0 < b <= 12):
    print("YYMM")
else:
    print("NA")
#!/usr/bin/env python3
s = input()
a=0<int(s[:2])<13
b=0<int(s[-2:])<13
if a and b:
    print('AMBIGUOUS')
elif b:
    print('YYMM')
elif a:
    print('MMYY')
else:
    print('NA')
S = int(input())
 
L = S // 100 # 前半2桁
R = S % 100 # 後半2桁
 
if 1 <= L <= 12:
  if 1 <= R <= 12: print('AMBIGUOUS')
  else: print('MMYY')
else:
  if 1 <= R <= 12: print('YYMM')
  else: print('NA')
s=int(input())
a=s//100
b=s%100

if a*b:
  if a<=12:
    if b<=12:
      print('AMBIGUOUS')
    else:
      print('MMYY')
  else:
    if b<=12:
      print('YYMM')
    else:
      print('NA')
else:
  if a:
    if a<=12:
      print('MMYY')
    else:
      print('NA')
  elif b:
    if b<=12:
      print('YYMM')
    else:
      print('NA')
  else:
    print('NA')
s = list(input())

a = 10*int(s[0])+int(s[1])
b = 10*int(s[2])+int(s[3])

if 0<a<13 and 0<b<13:
    print("AMBIGUOUS")
elif 0<a<13:
    print("MMYY")
elif 0<b<13:
    print("YYMM")
else:
    print("NA")
s = input()
be = int(s[0:2])
af = int(s[2:4]) 
if 0 < be < 13:
  if 1 <= af <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
elif 0 < af < 13:
  if 1 <= be <= 12:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  print('NA')
s = input()
x = int(s[:2])
y = int(s[2:])

if 1 <= x <= 12 and 1 <= y <= 12:
    print("AMBIGUOUS")
elif 1 <= x <= 12 and 0 <= y <= 99:
    print("MMYY")
elif 1 <= y <= 12 and 0 <= x <= 99:
    print("YYMM")
else:
    print("NA")
S = input()
a = int(S[:2])
b = int(S[2:])
ba = 1 <= a <= 12
bb = 1 <= b <= 12
if ba and bb:
    print('AMBIGUOUS')
elif ba and not bb:
    print('MMYY')
elif not ba and bb:
    print('YYMM')
else:
    print('NA')
S = input()
U = int(S[:2])
L = int(S[2:])

def month(n):
  if 1 <= n <= 12:
    return True
  else:
    return False

if month(U) == True and month(L) == True:
  print("AMBIGUOUS")
elif month(U) == True and month(L) == False:
  print("MMYY")
elif month(U) == False and month(L) == True:
  print("YYMM")
else:
  print("NA")
#B
s = input()

s_f = s[:2]
s_s = s[2:]

if (int(s_f) > 12 or int(s_f) == 0) and (int(s_s) > 12 or int(s_s) == 0):
    print('NA')
elif int(s_f) > 12 or int(s_f) == 0:
    print('YYMM')
elif int(s_s) > 12 or int(s_s) == 0:
    print('MMYY')

else:
    print('AMBIGUOUS')
s=list(input())
a=int(s[0])*10+int(s[1])
b=int(s[2])*10+int(s[3])
if (a>12 or a<1) and (b>12 or b<1):
  print("NA")
elif (a>12 or a<1):
  print("YYMM")
elif (b>12 or b<1):
  print("MMYY")
else:
  print("AMBIGUOUS")
from datetime import datetime

S = input()
a = S[:2]
b = S[2:]

def is_month(m):
    m = int(m)
    return 0 < m < 13

def is_year(y):
    y = int(y)
    return True

if is_month(a) and is_year(a) and is_month(b) and is_year(b):
    print("AMBIGUOUS")
elif is_month(a) and is_year(b):
    print("MMYY")
elif is_year(a) and is_month(b):
    print("YYMM")
else:
    print("NA")
S = str(input())

mae = str(S[:2])
ato = str(S[2:])

if (1 <= int(mae) <= 12) and (1 <= int(ato) <= 12):
  print('AMBIGUOUS')
elif (1 <= int(mae) <= 12):
  print('MMYY')
elif (1 <= int(ato) <= 12):
  print('YYMM')
else:
  print('NA')
S=input()
first = S[:2]
second= S[2:]
ans=""


if int(first) > 12 or int(first) == 0:#MM
	if int(second) <= 12 and int(second) >= 1:#YY
		ans="YYMM"
	if int(second) > 12 or int(second) == 0:#YY
		ans="NA"

elif int(first) <= 12 and int(first) >= 1:#YY
	if int(second) <= 12 and int(second) >= 1:#YY
		ans="AMBIGUOUS"
	if int(second) > 12 or int(second) == 0:#YY
		ans="MMYY"

print(ans)
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 12:19:27 2020

@author: shinba
"""

s = input()

B1 = (s[0] == "0" and s[1] != "0") or (s[0] == "1" and 0 <= int(s[1]) <= 2)
B2 = (s[2] == "0" and s[3] != "0") or (s[2] == "1" and 0 <= int(s[3]) <= 2)

if B1 and B2:
    print("AMBIGUOUS")
elif B1:
    print("MMYY")
elif B2:
    print("YYMM")
else:
    print("NA")
n = int(input())

d2 = n % 100
u2 = n // 100

if 1 <= d2 <= 12 and 1 <= u2 <= 12:
    print("AMBIGUOUS ")
elif 1 <= d2 <= 12:
    print("YYMM")
elif 1 <= u2 <= 12:
    print("MMYY")
else:
    print("NA")
S = list(input())

a = int("".join(S[0:2]))
b = int("".join(S[2:4]))

if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12:
    print("MMYY")
elif 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")
s = input()
a = int(s[:2])
b = int(s[2:])

if 0 < a <= 12:
    if 0 < b <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < b <= 12:
        print("YYMM")
    else:
        print("NA")
S = input()

former = int(S[:2])
latter = int(S[2:])

if 1 <= former <= 12 and 1 <= latter <= 12:
    print('AMBIGUOUS')
elif 1 <= former <= 12:
    print('MMYY')
elif 1 <= latter <= 12:
    print('YYMM')
else:
    print('NA')
a=input()
a_i=int(a[0:2])
b_i=int(a[2:4])
if 0<a_i<=12 and 0<b_i<=12:
    print('AMBIGUOUS')
elif 0<b_i<=12:
    print("YYMM")
elif 0<a_i<=12:
    print("MMYY")
else:
    print("NA")
s = int(input())
a = s % 100
b = ((s-a) / 100)
if a <= 12 and b <= 12 and a != 0 and b != 0:
  print("AMBIGUOUS")
elif b <= 12 and b != 0:
  print("MMYY")
elif a <= 12 and a != 0:
  print("YYMM")
else:
  print("NA")
S = input()
A = int(S[:2])
B = int(S[2:])

if 1<=A<=12 and 1<=B<=12:
  print("AMBIGUOUS")
elif 1<=A<=12:
  print("MMYY")
elif 1<=B<=12:
  print("YYMM")
else:
  print("NA")
#126_B
s=input()
y=int(s[:2])
m=int(s[2:])
if 1<=y<=12:
    if 1<=m<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=m<=12:
        print('YYMM')
    else:
        print('NA')
NUM = input()
Y1, M1 = int(NUM[:2]), int(NUM[2:])
Y2, M2 = M1, Y1

if 0 < M1 < 13 and 0 < M2 < 13:
    print("AMBIGUOUS")
elif 0 < M1 < 13:
    print("YYMM")
elif 0 < M2 < 13:
    print("MMYY")
else:
    print("NA")
n = input()
a = int(n[:2])
b = int(n[2:])

if 0 < a <= 12 and  (b == 0 or b > 12):
    print('MMYY')
elif (a == 0 or a > 12) and 0 < b <= 12:
    print('YYMM')
elif 0 < a <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
else:
    print('NA')
s = input()
first = int(s[:2])
second = int(s[2:])

month = [False,False]


if(1 <= first and first <= 12):
    month[0] = True

if(1 <= second and second <= 12):
    month[1] = True
    
if(month[0] & month[1]):
    print('AMBIGUOUS')
elif(month[0]):
    print('MMYY')
elif(month[1]):
    print('YYMM')
else:
    print('NA')
S = str(input())
year = int(S[0] + S[1])
month = int(S[2] + S[3])
if year <= 12 and year >= 1 and month >= 1 and month <= 12:
    print('AMBIGUOUS')
elif year >= 0 and year <= 99 and month >= 1 and month <= 12:
    print('YYMM')
elif year >= 1 and year <= 12 and month >= 0 and month <= 99:
    print('MMYY')
else:
    print('NA')
s=int(input())
a=s//100
b=s%100

if 1<=a<=12 and 1<=b<=12:
    print('AMBIGUOUS')
elif 1<=a<=12 and not 1<=b<=12:
    print('MMYY')
elif not 1<=a<=12 and 1<=b<=12:
    print('YYMM')
else:
    print('NA')
def main():
    s = int(input())
    f = int(s/100)
    b = s%100
    
    if f > 0 and f <= 12:
        if b > 0 and b <= 12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if b > 0 and b <= 12:
            print("YYMM")
        else:
            print("NA")

main()
S = input()

l = S[:2]
r = S[2:]

def isMonth(num):
  if 1 <= int(num) <= 12:
    return True
  else:
    return False
  
if isMonth(l) and isMonth(r):
  print("AMBIGUOUS")
elif isMonth(l):
  print("MMYY")
elif isMonth(r):
  print("YYMM")
else:
  print("NA")
s = list(input())
a = int("".join(s[:2]))
b = int("".join(s[2:]))
c = 0
d = 0
if a and a <= 12:
    c = 1
if b and b <= 12:
    d = 1
if c and d:
    print("AMBIGUOUS")
elif c:
    print("MMYY")
elif d:
    print("YYMM")
else:
    print("NA")
S = int(input())

a = S//100
b = S%100

if 1<=a<=12 and 1<=b<=12:
    print('AMBIGUOUS')
elif 1<=a<=12 and (b>12 or b==0):
    print('MMYY')
elif (a==0 or a>12) and 1<=b<=12:
    print('YYMM')
else:
    print('NA')
def chk(innum):
  if 1<=innum and innum<=12:
    return "MM"
  elif 0<=innum and innum<=99:
    return "YY"

s=input()
front=int(s[0:2])
back=int(s[2:4])
ans=chk(front)+chk(back)
if ans=="YYYY":
  ans="NA"
elif ans=="MMMM":
  ans="AMBIGUOUS"
print(ans)
S = str(input())

S_list = [int(S[:2]), int(S[2:])]


if 1 <= S_list[1] and S_list[1] <= 12 and 1 <= S_list[0] and S_list[0] <= 12:
    print('AMBIGUOUS')
elif 1 <= S_list[1] and S_list[1] <= 12:
    print('YYMM')
elif  1 <= S_list[0] and S_list[0] <= 12:
    print('MMYY')
else:
    print('NA')
def solve(yy,mm):
    if 1<=yy<=12:
        if 1 <= mm <=12:
            return 'AMBIGUOUS'
        else:
            return 'MMYY'
    else:
        if 1<= mm <= 12:
            return 'YYMM'
        else:
            return "NA"


s = input()
yy = int(s[:2])
mm = int(s[2:])
print(solve(yy,mm))
s = input()
first = 0 < int(s[:2]) < 13
second = 0 < int(s[2:]) < 13

if first and second:
    print('AMBIGUOUS')
elif first:
    print('MMYY')
elif second:
    print('YYMM')
else:
    print('NA')
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

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

S = input()
x, y = int(S[:2]), int(S[2:])
yymm = 1 <= y <= 12
mmyy = 1 <= x <= 12
if yymm and mmyy:
    print('AMBIGUOUS')
elif yymm:
    print('YYMM')
elif mmyy:
    print('MMYY')
else:
    print('NA')
S = int(input())
s1 = S//100
s2 = S%100

if s1 > 0 and s1 <=12:
  flag1 = True
else:
  flag1 = False
if s2 > 0 and s2 <=12:
  flag2 = True
else:
  flag2 = False
  
if flag1 and flag2:
  print("AMBIGUOUS")
if not flag1 and flag2:
  print("YYMM")
if flag1 and not flag2:
  print("MMYY")
if not flag1 and not flag2:
  print("NA")
S = input()
month_list = ["01","02","03","04","04","05","06","07","08","09","10","11","12"]

if S[0:2] in month_list:
    if S[2:4] in month_list:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if S[2:4] in month_list:
        print("YYMM")
    else:
        print("NA")
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=int(input())
a=s//100
b=s%100
if 0<a<13:
    if 0<b<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0<b<13:
        print("YYMM")
    else:
        print("NA")
S = input()
ot = S[:2]
tf = S[2:]

isotMM = 0
istfMM = 0

if 0 < int(ot) and int(ot) < 13:
    isotMM = 1
if 0 < int(tf) and int(tf) < 13:
    istfMM = 1
    
if isotMM == 1:
    if istfMM == 1:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if istfMM == 1:
        print('YYMM')
    else:
        print("NA")
s = input()
s1 = int(s[0:2])
s2 = int(s[2:])

if s1 > 0 and s1 < 13:
    if s2 > 0 and s2 < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if s2 > 0 and s2 < 13:
        print("YYMM")
    else:
        print("NA")
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=list(input())
def main():
    while True:
        if 1<=int(S[0]+S[1])<=12:
            if 1<=int(S[2]+S[3])<=12:
                return 'AMBIGUOUS'
            else:
                return 'MMYY'
        else:
            if 1<=int(S[2]+S[3])<=12:
                return 'YYMM'
            else:
                return 'NA'

print(main())
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
if 1<=s1<=12 and 1<=s2<=12:
    print('AMBIGUOUS')
elif 1<=s1<=12:
    print('MMYY')
elif 1<=s2<=12:
    print('YYMM')
else:
    print('NA')
S = input()
L = int(S[:2])
R = int(S[2:])

if 1<=L<=12 and 1<=R<=12:
  print("AMBIGUOUS")
elif 1<=L<=12:
  print("MMYY")
elif 1<=R<=12:
  print("YYMM")
else:
  print("NA")
S = input()
pre = int(S[:2])
sur = int(S[2:])
if pre <= 12 and pre > 0 and sur <= 12 and sur > 0:
    print('AMBIGUOUS')
elif pre <= 12 and pre > 0:
    print('MMYY')
elif sur <= 12 and sur > 0:
    print('YYMM')
else:
    print('NA')
S = int(input())
s_1 = S // 100
s_2 = S % 100

if 1 <= s_1 <= 12 and 1 <= s_2 <= 12:
    print('AMBIGUOUS')
elif 1 <= s_1 <= 12 and (s_2 < 1 or s_2 > 12):
    print('MMYY')
elif 1 <= s_2 <= 12 and (s_1 < 1 or s_1 > 12):
    print('YYMM')
else:
    print('NA')
def main():
  S=int(input())
  a=S//100
  b=S%100
  if 1<=a<=12 and 1<=b<=12:
    print("AMBIGUOUS ")
  elif 1<=a<=12 and (b==0 or 13<=b<=99):
    print("MMYY")
  elif 1<=b<=12 and (a==0 or 13<=a<=99):
    print("YYMM")
  else:
    print("NA")
main()
s = input()

if int(s[:2]) >= 1 and int(s[:2]) <= 12 and int(s[2:]) >= 1 and int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif int(s[:2]) >= 1 and int(s[:2]) <= 12:
    print('MMYY')
elif int(s[2:]) >= 1 and int(s[2:]) <= 12:
    print('YYMM')
else:
    print('NA')
s=str(input())
a=int(s[0:2])
b=int(s[2:4])

if 1<=a<=12:
    if 1<=b<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=b<=12:
        print("YYMM")
    else:
        print("NA")
S = input()
YYMM = 0
MMYY = 0
start = S[0:2]
end = S[2:4]
tmp1 = int(start)
tmp2 = int(end)
if(tmp2 <= 12 and tmp2 != 0):
    YYMM = 1
if(tmp1 <= 12 and tmp1 != 0):
    MMYY = 1
if(YYMM == 1 and MMYY == 1):
    print("AMBIGUOUS")
elif(YYMM == 1):
    print("YYMM")
elif(MMYY == 1):
    print("MMYY")
else:
    print("NA")
s = int(input())

a = s % 100
b = (s-a) / 100

if a >= 1 and a <= 12:
    if b >= 1 and b <= 12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if b >= 1 and b <= 12:
        print('MMYY')
    else:
        print('NA')
S = input()

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

if int(S[0:2]) > 12 or S[0:2] == "00":
    if 0 < int(S[2:4]) <= 12:
        print("YYMM")
    else:
        print("NA")
else:
    if 0 < int(S[2:4]) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
S=input()
a=int(S[:2])
b=int(S[2:])
if((0<a and a<=12)and(0<b and b<=12)):
  print("AMBIGUOUS")
elif(not(0<a and a<=12)and(0<b and b<=12)):
  print("YYMM")
elif((0<a and a<=12)and not(0<b and b<=12)):
  print("MMYY")
else:
  print("NA")
S = input()
AS = S[:2]
BS = S[2:]
if 1<=int(AS)<=12 and 1<=int(BS)<=12:
    print('AMBIGUOUS')
elif 1<=int(AS)<=12:
    print('MMYY')
elif 1<=int(BS)<=12:
    print('YYMM')
else:
    print('NA')
s = input()
a, b = int(s[:2]), int(s[2:])

if 0<a<13 and 0<b<13:
    ans = 'AMBIGUOUS'
elif 0<a<13 and (b>12 or b==0):
    ans = 'MMYY'
elif (a>12 or a==0) and 0<b<13:
    ans = 'YYMM'
else:
    ans = 'NA'

print(ans)
s = input()
head = int(s[:2])
tail = int(s[2:])


def is_only_year(a):
    return a == 0 or a > 12


def is_month(a):
    return 0 < a <= 12


if is_only_year(head) and is_month(tail):
    print("YYMM")
elif is_month(head) and is_only_year(tail):
    print("MMYY")
elif is_month(head) and is_month(tail):
    print("AMBIGUOUS")
else:
    print("NA")
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
ans = ''
xx = int(s[0:2])
zz = int(s[2:4])
if xx < 13 and zz < 13 and xx != 0 and zz != 0:
    ans = 'AMBIGUOUS'
elif xx < 13 and xx != 0:
    ans = 'MMYY'
elif zz < 13 and zz != 0:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)
n=int(input())
front=n//100
back=n%100
if 1<=front<=12 and 1<=back<=12:
    print("AMBIGUOUS")
elif 1<=front<=12:
    print("MMYY")
elif 1<=back<=12:
    print("YYMM")
else:
    print("NA")
s = input()
ans = 0
for i in range(0,3,2):
  if s[i] == "0" and s[i+1] == "0":
    continue
  elif s[i] == "0":
    ans += i+1
  elif (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") or (s[i] == "1" and s[i+1] == "2"):
    ans += i+1
if ans == 1:
  print("MMYY")
elif ans == 3:
  print("YYMM")
elif ans == 4:
  print("AMBIGUOUS")
else:
  print("NA")
s=input()
s1=int(s[:2])
s2=int(s[2:])

if 1<=s1<=12 and 1<=s2<=12:
  print("AMBIGUOUS")
elif 0<=s1<=99 and 1<=s2<=12:
  print("YYMM")
elif 1<=s1<=12 and 0<=s2<=99:
  print("MMYY")
else:
  print("NA")
n = input()
a = int(n[:2])
b = int(n[2:])
x = 0 < a <= 12
y = 0 < b <= 12
if x and y :
    print('AMBIGUOUS')
elif not x and y:
    print('YYMM')
elif x and not y:
    print('MMYY')
else:
    print('NA')
N=int(input(" "))
Y=N%100
M=N//100
if M>11:
    print("YYMM")
elif Y>11:
    print("MMYY")
elif M<13:
    print("AMBIGUOUS")
elif M==0 or Y==0:
    print("NA")
s = list(input())
ans = 'NA'
if 12 < int(s[0]+s[1]):
    if 1<=int(s[2]+s[3]) and int(s[2]+s[3])<=12:
        ans = 'YYMM'
else:
    if 1<=int(s[0]+s[1]) and int(s[0]+s[1])<=12:
        ans = 'AMBIGUOUS'
print(ans)
s = input()
n1 = int(s[:2])
n2 = int(s[2:])
if 1 <= n1 <= 12 and 1 <= n2 <= 12:
    print("AMBIGUOUS")
elif n1 > 12 and 1 <= n2 <= 12:
    print("YYMM")
elif 1 <= n1 <= 12 and n2 > 12:
    print("MMYY")
else:
    print("NA")
s=input()
f=int(s[:2])
b=int(s[2:4])

if b>=13 or b==0:
    print('NA')
elif f>=13:
    print('YYMM')
else:
    print('AMBIGUOUS')
S = input()

if S[:2] == '00' or S[2:] == '00':
    print('NA')
elif int(S[:2]) <= 12 and int(S[2:]) <= 12:
    print('AMBIGUOUS')
elif int(S[:2]) <= 12:
    print('MMYY')
elif int(S[2:]) <= 12:
    print('YYMM')
else:
    print('NA')
def main():
    S = input()
    if int(S[:2]) > 12 and 12 >= int(S[2:]) > 0:
        print("YYMM")
    elif 0 < int(S[2:]) <= 12 and 12 < int(S[:2]):
        print("MMYY")
    elif 0 < int(S[:2]) <= 12 and 0 < int(S[2:]) <= 12:
        print("AMBIGUOUS")
    else:
        print("NA")


if __name__ == '__main__':
    main()
s=input()
f=int(s[:2])
b=int(s[2:])
if f>=13:
	if 0<b and b<13:
		print("YYMM")
	else:
		print("NA")
elif 0<f and f<13:
	if 0<b and b<13:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	print("NA")
S = input()

highInt = int(S[0:2])
lowInt =int(S[2:4])

if highInt < 13 and lowInt < 13:
    ans = 'AMBIGUOUS'
elif highInt > 12 and lowInt > 12:
    ans = 'NA'
elif highInt < 13:
    ans = 'MMYY'
else:
    ans = 'YYMM'

print(ans)
x = input()
a, b = int(x[0:2]), int(x[2:4])
flag = 0
ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"]

if (a >= 1 and a <= 12) and (b >= 1 and b <= 12):
    flag = 0
elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12):
    flag = 3
elif (a > 0 and a <= 12) and (b >= 13):
    flag = 2
elif (a >= 13) and (b > 0 and b <= 12):
    flag = 1


print(ans[flag])
S = input()
f, r = S[:2], S[2:]
if f == "00" or r == "00" or (int(f)>12 and int(r)>12):
  ans = "NA"
elif int(f) > 12 and int(r) <= 12:
  ans = "YYMM"
elif int(r) > 12 and int(f) <= 12:
  ans = "MMYY"
else:
  ans = "AMBIGUOUS"
print(ans)
S = str(input())
year = int(S[0] + S[1])
month = int(S[2] + S[3])
if year <= 12 and year >= 1 and month >= 1 and month <= 12:
    print('AMBIGOUS')
elif year >= 1 and year <= 99 and month >= 1 and month <= 12:
    print('YYMM')
elif year >= 12 and year <= 12 and month >= 1 and month <= 99:
    print('MMYY')
else:
    print('NA')
S = list(input())

S = list(map(int, S))

if S[0] == S[1] == 0 or S[2] == S[3] == 0 or (S[0] > 1 and S[2] > 1):
    print("NA")
elif S[2] > 1 or (S[2] == 1 and S[3] > 2):
    print("MMYY")
elif S[0] > 1 or (S[0] == 1 and S[1] > 2):
    print("YYMM")
else:
    print("AMBIGUOUS")
s = input()

s1 = int(s[0:2])
s2 = int(s[2:4])

s1m = False
s1y = False
s2m = False
s2y = False
if s1 <= 12 and s1 >= 1:
  s1y = True
  s1m = True
elif s1 > 12 :
  s1y = True
  
if s2 <= 12 and s2 >= 1:
  s2y = True
  s2m = True
elif s2 > 12 :
  s2y = True

if s1y and s2y and s1m and s2m:
  print("AMBIGUOUS")
elif s1y and s2m :
  print("YYMM")
elif s2y and s1m :
  print("MMYY")
else :
  print("NA")
S = input()
f,e = int(S[:2]),int(S[2:])
if f>12:
  if 1<=e<=12:
    print('YYMM')
  else:
    print('NA')
elif 1<=f<=12:
  if e>12:
    print('MMYY')
  elif 1<=e<=12:
    print('AMBIGUOUS')
  else:
    print('NA')
else:
  print('NA')
def resolve():
    S = list(input())

    front = int(''.join(S[:2]))
    back = int(''.join(S[2:]))

    if (0 == front or 0 == back):
        print('NA')
        return

    if (front <= 12 and back <= 12):
        print('AMBIGUOUS')
        return

    if (front > 12 and back <= 12):
        print('YYMM')
        return

    if (front <= 12 and back > 12):
        print('MMYY')
        return

    print('NA')

resolve()
s = input()

if '00' in s:
    print('NA')
elif int(s[:2]) <= 12 and int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif int(s[2:]) > 13:
    print('MMYY')
elif int(s[:2]) > 13:
    print('YYMM')
else:
    print('NA')
s = input()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
if s1 == s2 == 0:
    print('NA')
elif s1 <= 12 and s2 <= 12:
    print('AMBIGUOUS')
elif s1 <= 12:
    print('MMYY')
elif s2 <= 12:
    print('YYMM')
else:
    print('NA')