peterverebics/CodeNet_Python_118 huggingface dataset:
a, b = divmod(int(input()), 100)
x = "MM" if 0 < a < 13 else "YY"
y = "MM" if 0 < b < 13 else "YY"
print(x + y if x != y else "NA" if x == "YY" else "AMBIGUOUS")
s=input()

x=int(s[:2])
y=int(s[2:])

if (1<=x<=12) and (1<=y<=12):
    print('AMBIGUOUS')

elif (x==0 or x>12) and (1<=y<=12):
    print('YYMM')

elif (1<=x<=12) and (y==0 or y>12):
    print('MMYY')

else:
    print('NA')
a=input()
b=int(a[0]+a[1])
c=int(a[2]+a[3])
if 1<=b<=12:
  if 1<=c<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=c<=12:
    print("YYMM")
  else:
    print("NA")
def main():
    S = input()
    if 0 < int(S[:2]) <= 12 and 0 < int(S[2:]) <= 12:
        return "AMBIGUOUS"
    elif (int(S[:2]) > 12 or int(S[:2]) == 0) and 12 >= int(S[2:]) > 0:
        return "YYMM"
    elif 0 < int(S[:2]) <= 12 and (12 < int(S[2:]) or int(S[2:]) == 0):
        return "MMYY"
    else:
        return "NA"


if __name__ == '__main__':
    print(main())
S = int(input())

front = S // 100
back = S % 100

if 1 <= front <= 12 :
    if  1 <= back <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= back <= 12:
        print("YYMM")
    else:
        print("NA")
s = int(input())
s_1 = s // 100 #4桁の数字列の上2桁を取り出す
s_2 = s % 100  #4桁の数字列の下2桁を取り出す

if 1 <= s_1 <=12 and 1 <= s_2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s_1 <= 12:
    print("MMYY")
elif 1 <= s_2 <= 12:
    print("YYMM")
else:
    print("NA")
S = input()
 
if int(S[:2]) > 12 or int(S[:2]) == 0:
  if int(S[2:]) > 12 or int(S[2:]) == 0: print('NA')
  else: print('YYMM')
else:
  if int(S[2:]) > 12 or int(S[2:]) == 0: print('MMYY')
  else: print('AMBIGUOUS')
s=input()
if 0<int(s[:2])<=12 and 0<int(s[2:])<=12:
    print("AMBIGUOUS")
elif 0<int(s[:2])<=12:
    print("MMYY")
elif 0<int(s[2:])<=12:
    print("YYMM")
else:
    print("NA")
S = input()
a = S[:2]
b = S[2:]
ans = ""
if 1<=int(a)<=12: ans += "MM"
else: ans += "YY"
if 1<=int(b)<=12: ans += "MM"
else: ans += "YY"

if ans in ["YYMM", "MMYY"]: print(ans)
elif ans == "MMMM": print("AMBIGUOUS")
else: print("NA")
s = input()
a = int(s[:2])
b = int(s[2:])
if a >= 1 and a <= 12:
  if b >= 1 and b <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if b >= 1 and b <= 12:
    print('YYMM')
  else:
    print('NA')
s=input()
yy = ["%02d" % i for i in range(100)]
mm = ["%02d" % i for i in range(1, 13)]
yymm = s[:2] in yy and s[2:] in mm
mmyy = s[:2] in mm and s[2:] in yy
print(["NA","MMYY","YYMM","AMBIGUOUS"][yymm*2+mmyy])
s = input()
if 0 < int(s[:2]) <= 12:
  if int(s[2:]) > 12 or int(s[2:]) == 0:
    print('MMYY')   
  else:
    print('AMBIGUOUS')
else:
  if 0 < int(s[2:]) <= 12:
    print('YYMM')   
  else:
    print('NA')
S1, S2, S3, S4 = input()
Front = 10 * int(S1) + int(S2)
Back  = 10 * int(S3) + int(S4)

if 1 <= Front <= 12 and 1 <= Back <= 12:
    print('AMBIGUOUS')
elif (Front > 12 or Front == 0) and 1 <= Back <= 12:
    print('YYMM')
elif 1 <= Front <= 12 and (Back > 12 or Back == 0):
    print('MMYY')
else:
    print('NA')
S = list(map(str, input()))

F = int(S[0]+S[1])
L = int(S[2]+S[3])

if (L == 0 and F == 0) or (F > 12 and L > 12) or (F == 0 and L > 12) or (L == 0 and F > 12):
  print('NA')

elif F <= 12 and (L > 12 or L == 0):
  print('MMYY')
  
elif L <= 12 and (F > 12 or F == 0):
  print('YYMM')
  
 
else:
  print('AMBIGUOUS')
#input
S = str(input())

#output
S1 = int(S[:2])
S2 = int(S[2:])

if S1 == 0 and S2 == 0:
    print("NA")
elif S1 ==0 and 0 < S2 <= 12:
    print("YYMM")
elif S1 == 0 and S2 > 12:
    print("NA")
elif S2 == 0 and S1 > 12:
    print("NA")
elif S2 == 0 and 0 < S1 <= 12:
    print("MMYY")
elif 0 < S1 <= 12 and 0 < S2 <= 12:
    print("AMBIGUOUS")
elif S1 > 12 and 0 < S2 <= 12:
    print("YYMM")
elif 0 < S1 <= 12 and S2 > 12:
    print("MMYY")
elif S1 > 12 and S2 > 12:
    print("NA")
S = input()
s0 = 0 < int(S[:2]) <= 12
s1 = 0 < int(S[2:]) <= 12
if s0 and s1:
    print('AMBIGUOUS')
elif s0 and not s1:
    print('MMYY')
elif not s0 and s1:
    print('YYMM')
else:
    print('NA')
S = input()
a = int(S[0:2])
b = int(S[2:4])
if 1<=a<=12:
    if 1<=b<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 1<=b<=12:
    print('YYMM')
else:
    print('NA')
s = input()
if 0 < int(s[:2]) <13 and 0< int(s[2:]) < 13:
    print("AMBIGUOUS")
elif 0 < int(s[:2]) < 13:
    print("MMYY")
elif 0 < int(s[2:]) < 13:
    print("YYMM")
else:
    print("NA")
s = input()
YYMM = False
MMYY = False

if 1 <= int(s[:2]) <= 12:
    MMYY = True
if 1 <= int(s[2:]) <= 12:
    YYMM = True

ans = ''
if YYMM and MMYY:
    ans = 'AMBIGUOUS'
elif YYMM:
    ans = 'YYMM'
elif MMYY:
    ans = 'MMYY'
else:
    ans = 'NA'

print(ans)
s = input()
s12 = int(s[0:2])
s34 = int(s[2:])

if (0 < s12 < 13) and(0 < s34 < 13):
  print("AMBIGUOUS")
elif 0 < s12 < 13:
  print("MMYY")
elif 0 < s34 < 13:
  print("YYMM")
else:
  print("NA")
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = list(sr())
head = int(''.join(S[:2]))
tail = int(''.join(S[2:]))
bl_head = (1 <= head <= 12)
bl_tail = (1 <= tail <= 12)
if bl_head and bl_tail:
    answer = "AMBIGUOUS"
elif bl_head:
    answer = "MMYY"
elif bl_tail:
    answer = "YYMM"
else:
    answer = "NA"

print(answer)
n = list(input())
x = int(n[0]+n[1])
y = int(n[2]+n[3])

if 1 <= x and x <= 12:
  if 1 <= y and y <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
elif 1 <= y and y <= 12:
  print("YYMM")
else:
  print("NA")
n = input()
s, t = (1 <= int(n[:2]) <= 12), (1 <= int(n[2:]) <= 12)
print("AMBIGUOUS" if s and t else "YYMM" if t else "MMYY" if s else "NA")
s=input()
ans=[0]*2
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12:
    ans[0]=1
if 1<=b<=12:
    ans[1]=1

if ans[0]==ans[1]==1:
    print('AMBIGUOUS')
elif ans[0]==ans[1]==0:
    print('NA')
elif ans[0]==1 and ans[1]==0:
    print('MMYY')
else:
    print('YYMM')
S = int(input())
a = S % 100
b = (S- (S % 100))/100
if   b <= 12 and  a<=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()
f = int(S[:2])
e = int(S[2:])
if 1 <= f <= 12 and (e > 12 or e == 0):
    print('MMYY')
elif (f > 12 or f == 0) and 1 <= e <= 12:
    print('YYMM')
elif 1 <= f <= 12 and 1 <= e <= 12:
    print('AMBIGUOUS')
else:
    print('NA')
S = input()
a, b = S[0:2], S[-2:]

if "00" < a <= "12":
    if "00" < b <= "12":
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif "00" < b <= "12":
    print("YYMM")
else:
    print("NA")
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
MMYY = False
YYMM = False
if 0<s1<13:
    MMYY = True
if 0<s2<13:
    YYMM = True
if MMYY and YYMM:
    print('AMBIGUOUS')
elif MMYY:
    print('MMYY')
elif YYMM:
    print('YYMM')
else:
    print('NA')
s=str(input())
if 1<=int(s[:2])<=12 and 1<=int(s[2:])<=12:
  print("AMBIGUOUS")
elif 1<=int(s[:2])<=12:
  print("MMYY")
elif 1<=int(s[2:])<=12:
  print("YYMM")  
else:
  print("NA")
a=input()
n=int(a[0:2])
m=int(a[2:4])
if 0<n<=12 and 0<m<=12:
    print('AMBIGUOUS')
elif 0<n<=12:
    print('MMYY')
elif 0<m<=12:
    print('YYMM')
else:
    print('NA')
s = input()
s1 = s[:2]
s2 = s[2:]
if (int(s1) <= 12 and int(s1) >= 1) and (int(s2) <= 12 and int(s2) >= 1):
  print('AMBIGUOUS')
elif ((int(s1) == 0) or int(s1) > 12) and (int(s2) <= 12 and int(s2) >= 1):
  print('YYMM')
elif ((int(s2) == 0) or (int(s2) > 12)) and (int(s1) <= 12 and int(s1) >= 1):
  print('MMYY')
else:
  print('NA')
def main():
    S = input()
    first = int(S[0:2])
    last = int(S[2:4])

    if((first>12 or first==0) and last<=12 and last>=1):
        print("YYMM")
    elif((last>12 or last==0) and first<=12 and first>=1):
        print("MMYY")
    elif(last<=12 and first<=12 and last>=1 and first>=1):
        print("AMBIGUOUS")
    else:
        print("NA")
    
    return
main()
S=input()
months=['01','02','03','04','05','06','07','08','09','10','11','12']

if S[0:2] in months and S[2:4] in months:
    print('AMBIGUOUS')
elif S[0:2] in months:
    print('MMYY')
elif S[2:4] in months:
    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 and s1 >= 1 and s2 >= 1:
    print('AMBIGUOUS')
elif s1 <= 12 and s1 >= 1:
    print('MMYY')
elif s2 <= 12 and s2 >= 1:
    print('YYMM')
else:
    print('NA')
s=input()
YYMM=MMYY=False
if s[:2]<="12" and s[:2]>="01":
    MMYY=True
if s[2:]<="12" and s[2:]>="01":
    YYMM=True
if YYMM and MMYY:
    print("AMBIGUOUS")
elif YYMM:
    print("YYMM")
elif MMYY:
    print("MMYY")
else:
    print("NA")
s=input()
s1=int(s[0]+s[1])
s2=int(s[2]+s[3])
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")
import sys

input = sys.stdin.readline


def main():
  S = input().strip()
  s, t = int(S[:2]), int(S[2:])
  
  s_mm = (1 <= s <= 12)
  t_mm = (1 <= t <= 12)
  
  mapping = {
    (True, True): 'AMBIGUOUS',
    (True, False): 'MMYY',
    (False, True): 'YYMM',
    (False, False): 'NA'
  }
  
  print(mapping[(s_mm, t_mm)])



if __name__ == '__main__':
  main()
s = input()
YYMM, MMYY, ova = False, False, False
if(1 <= int(s[:2]) <= 12):
    MMYY = True
if(1 <= int(s[2:]) <= 12):
    YYMM = True

if(MMYY and YYMM):
    print('AMBIGUOUS')
elif(MMYY):
    print("MMYY")
elif(YYMM):
    print('YYMM')
else:
    print('NA')
n = list(input())
a=int(n[0]+n[1]) #4桁の数値の前2桁
b=int(n[2]+n[3]) #4桁の数値の後2桁

if 1<= a <=12:
    if 1<= b <=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 1<= b <=12:
    print('YYMM')
else:
    print('NA')
S = input()
flagA = False
flagB = False
if 1 <= int(S[2:4])<= 12:
  flagB = True
if 1 <= int(S[0:2])<= 12:
  flagA = True
if flagA and flagB:
  print("AMBIGUOUS")
elif flagA and not flagB:
  print("MMYY")
elif flagB and not flagA:
  print("YYMM")
else:
  print("NA")
x = int(input())

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

fa = False
fb = False

if 0 < a <= 12:
    fa = True
if 0 < b <= 12:
    fb = True
if fa & fb:
    print("AMBIGUOUS")
elif fa:
    print("YYMM")
elif fb:
    print("MMYY")
else:
    print("NA")
s = input()
mae = int(s[:2])
ush = int(s[2:])

if 1<=mae<=12:
    if 1<=ush<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=ush<=12:
        print('YYMM')
    else:
        print('NA')
S = input()
f = int(S[:2])
s = int(S[2:])
t1 = False
t2 = False
if(f > 0 and f < 13):
    t1 = True
if(s > 0 and s < 13):
    t2 = True
if(t1 == True):
    if(t2 == True):print('AMBIGUOUS')
    else:print('MMYY')
else:
    if(t2 == True):print('YYMM')
    else:print('NA')
s = int(input())
a = s//100
b = s%100
if 0 < b and b < 13 and 0 < a and a < 13:
    print("AMBIGUOUS")
elif 0 < b and b < 13:
    print("YYMM")
elif 0 < a and a < 13:
    print("MMYY")
else:
    print("NA")
s = input()
mae = int(s[:2])
usiro = int(s[2:])

ym = 0
my = 0

if (1 <= usiro <= 12): ym = 1
if (1 <= mae <= 12): my = 1

if (ym and my): print("AMBIGUOUS")
elif (ym): print("YYMM")
elif (my): print("MMYY")
else: print("NA")
def solve_128b(a, b):
    if 1 <= a & a <= 12:
        if 1 <= b & b <= 12:
            return "AMBIGUOUS"
        else:
            return "MMYY"
    else:
        if 1 <= b & b <= 12:
            return "YYMM"
        else:
            return "NA"

s = int(input())
s2 = int(s / 100)
s1 = s % 100
print(solve_128b(s2, s1))
#126
s = input()

a = int(s[0:2])
b = int(s[2:])

res = ""
if 1 <= a and a <= 12:
    if 1 <= b and b <= 12:
        res = "AMBIGUOUS"
    else:
        res = "MMYY"
else:
    if 1 <= b and b <= 12:
        res = "YYMM"
    else:
        res = "NA"
print(res)
S = input()
A = int(S[0:2])
B = int(S[2:4])

if (0 < A) and (A <= 12):
    if (0 < B) and (B <= 12):
        print('AMBIGUOUS')
    else:
        print('MMYY')

else:
    if (0 < B) and (B <= 12):
        print('YYMM')
    else:
        print('NA')
S = input()
MM = ["01","02","03","04","05","06","07","08","09","10","11","12"]

if S[:2] in MM and S[2:] in MM:
  print("AMBIGUOUS")
elif S[:2] in MM:
  print("MMYY")
elif S[2:] in MM:
  print("YYMM")
else:
  print("NA")
S = input()
a,b = int(S[:2]),int(S[2:])
if (1<=a and a<=12) or (1<=b and b<=12):
    if (1<=a and a<=12) and (1<=b and b<=12): 
        print("AMBIGUOUS")
    elif (1<=b and b<=12):
        print("YYMM")
    elif  (1<=a and a<=12): 
        print("MMYY")
  
else:
    print("NA")
def q2():
    S = int(input())
    d, m = divmod(S, 100)

    is_YYMM, is_MMYY = False, False
    if 1 <= d <= 12:
        is_MMYY = True
    if 1 <= m <= 12:
        is_YYMM = True

    if is_MMYY:
        if is_YYMM:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    else:
        if is_YYMM:
            print('YYMM')
        else:
            print('NA')


if __name__ == '__main__':
    q2()
S = input()

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

if 1 <= mae <= 12 and 1 <= ato <= 12:
  print("AMBIGUOUS")
elif 1 <= ato <= 12:
  print("YYMM")
elif 1 <= mae <= 12:
  print("MMYY")
else:
  print("NA")
s = list(map(int, input()))
l = [0]*2
l[0] = s[0]*10 + s[1]
l[1] = s[2]*10 + s[3]

F = False
L = False

if 0 < l[0] <= 12:
  F = True
if 0 < l[1] <= 12:
  L = True

if F == True and L == True:
  print('AMBIGUOUS')

elif F == True:
  print('MMYY')

elif L == True:
  print('YYMM')

else:
  print('NA')
s=input()
flag1=0
flag2=0
if 0<int(s[:2])<13:
  flag1=1
else:
  pass
if 0<int(s[2:])<13:
  flag2=1
else:
  pass

if flag1==0 and flag2==0:
  print("NA")
elif flag1==1 and flag2==0:
  print("MMYY")
elif flag1==0 and flag2==1:
  print("YYMM")
else:
  print("AMBIGUOUS")
s = input()
f, b = int(s[:2]), int(s[2:])
if ((0 < f and f <= 12) and (b > 12 or b == 0)): print("MMYY")
elif ((0 < b and b <= 12) and (f > 12 or f == 0)): print("YYMM")
elif (f == 0 or b == 0 or (f > 12 and b > 12)): print("NA")
else: print("AMBIGUOUS")
s = str(input())
ans = ['YYMM','MMYY','AMBIGUOUS','NA']
#print(s[:2],s[-2:])
if (0==int(s[:2]) or 13<=int(s[:2])) and (0==int(s[-2:]) or 13<=int(s[-2:])):
    print(ans[3])
if 0<int(s[:2])<=12 and 0<int(s[-2:])<=12:
    print(ans[2])
elif 0<int(s[:2])<=12:
    print(ans[1])
elif 0<int(s[-2:])<=12:
    print(ans[0])
s = input()
former = s[:2]
latter = s[2:]
#前者がMMの可能性
if int(former) >= 1 and int(former) <= 12:
    if int(latter) >= 1 and int(latter) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if int(latter) >= 1 and int(latter) <= 12:
        print("YYMM")
    else:
        print("NA")
s = str(input())
num = ['01','02','03','04','05','06','07','08','09','10','11','12']
if s[:2] in num and s[2:] in num:
    print("AMBIGUOUS")
elif s[:2] in num:
    print("MMYY")
elif s[2:] in num:
    print("YYMM")
else:
    print("NA")
num = list(map(int, input()))

f = num[0]*10 + num[1]
b = num[-2]*10 + num[-1]

if 0 < f <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
elif 0 < f <= 12:
    print('MMYY')
elif 0 < b <= 12:
    print('YYMM')
else:
    print('NA')
import sys
S = list(input())
S = [S[0]+S[1],S[2]+S[3]]
month = ['01','02','03','04','05','06','07','08','09','10','11','12']

# 月表示、年表示についてのステータス
# [前表示、後ろ表示]
mon = [0,0]
yer = [0,0]

if S[0] in month:
	mon[0] = 1
if S[1] in month:
	mon[1] = 1


if mon[0] == 1 and mon[1] == 1:
	print('AMBIGUOUS')
	sys.exit()
if mon[0] == 1:
	print('MMYY')
	sys.exit()
if mon[1] == 1:
	print('YYMM')
	sys.exit()
else:
	print('NA')
	sys.exit()
s = input()

ans = [0, 0]
for i in range(100):
    for j in range(1, 13):
        if str(i).zfill(2) + str(j).zfill(2) == s:
            ans[0] = 1
        if str(j).zfill(2) + str(i).zfill(2) == s:
            ans[1] = 1

if sum(ans) == 2:
    print("AMBIGUOUS")
elif ans[0] == 1:
    print("YYMM")
elif ans[1] == 1:
    print("MMYY")
else:
    print("NA")
import math
import sys
import numpy as np

def int_input():
    return map(int, input().split())

s = input()

flag = 0
if 1 <= int(s[:2]) <= 12: flag += 2
if 1 <= int(s[2:]) <= 12: flag += 1

ans = ["NA", "YYMM", "MMYY", "AMBIGUOUS"]
print(ans[flag])
s = input()
# YYMM
aa = int(s[0]+s[1])
bb = int(s[2]+s[3])
if aa>=13 or aa==0:
    if 0<bb<13:
        print('YYMM')
    else:
        print('NA')
else:
    if 0<bb<13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
s = input()

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

if 1 <= a <= 12 and 1 <= b <= 12:
    ans = "AMBIGUOUS"
elif 1 <= a <= 12:
    ans = "MMYY"
elif 1 <= b <= 12:
    ans = "YYMM"
else:
    ans = "NA"
print(ans)
s = list(input())
l = int(s[0]+s[1])
r = int(s[2]+s[3])
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()
s1=s[0]+s[1]
s2=s[2]+s[3]
n1=int(s1)
n2=int(s2)
if 1<=n1<=12:
    if 1<=n2<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=n2<=12:
        print('YYMM')
    else:
        print('NA')
s = input()

if 0 < int(s[:2]) <= 12 and 0 < int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif 0 < int(s[:2]) <= 12 and int(s[2:]) >= 12:
    print('MMYY')
elif 0 < int(s[:2]) < 12 and int(s[2:]) == 0:
    print('MMYY')
elif int(s[:2]) >= 12 > 0 and 0 < int(s[2:]) <= 12:
    print('YYMM')
elif int(s[:2]) == 0 and 0 < int(s[2:]) <= 12:
    print('YYMM')
else:
    print('NA')
S = input()
S = list(S)
S1 = S[0] + S[1]
S1 = int(S1)
S2 = S[2] + S[3]
S2 = int(S2)

if 1 <= S1 and S1 <= 12:
    if 1 <= S2 and S2 <=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
    
elif 1 <= S2 and S2 <= 12:
    print("YYMM")

else:
    print("NA")
S = input()

if (1 <= int(S[:2]) <= 12) and (1 <= int(S[2:4]) <= 12):
    print('AMBIGUOUS')
elif (0 <= int(S[:2]) <= 99) and (1 <= int(S[2:4]) <= 12):
    print('YYMM')
elif (1 <= int(S[:2]) <= 12) and (0 <= int(S[2:4]) <= 99):
    print('MMYY')
else:
    print('NA')
S=input().strip()
a=int(S[:2])
b=int(S[2:])
aa = a < 13 and a != 0
bb = b < 13 and b != 0

if aa and bb:
    ans = 'AMBIGUOUS'
elif aa and not bb:
    ans = 'MMYY'
elif bb and not aa:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)
yymm = input()

if (1 <= int(yymm[0:2]) and int(yymm[0:2]) <= 12) and (1 <= int(yymm[2:4]) and int(yymm[2:4]) <= 12):
    print('AMBIGUOUS')
elif (1 <= int(yymm[0:2]) and int(yymm[0:2]) <= 12) and int(yymm[2:4]) <= 99:
    print('MMYY')
elif int(yymm[0:2]) <= 99 and (1 <= int(yymm[2:4]) and int(yymm[2:4]) <= 12):
    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 = map(int,list(f(raw_input())))
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[(p,q)]
s = input()
a = int(s[:2]) #上2桁
b = int(s[2:]) #下2桁

if 0 < a < 13:
    if 0 < b < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < b < 13:
        print('YYMM')
    else:
        print('NA')
def aaa(s):
  if s[0]=='0':
    if s[1]=='0':
      return 'y'
    return 'm'
  elif s[0]=='1':
    if int(s[1])<3:
      return 'm'
  return 'y'
  
s = input()
l = aaa(s[:2])
r = aaa(s[2:])
if l=='m' and r=='m':
  print('AMBIGUOUS')
elif l=='m' and r=='y':
  print('MMYY')
elif l=='y' and r=='m':
  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 <= R <= 12:
    print('YYMM')
elif 1 <= L <= 12:
    print('MMYY')
else:
    print('NA')
# -*- coding: utf-8 -*-

s = input()

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

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=list(input())
S=[]
for i in range(len(s)):
    S.append(int(s[i]))
if 1<=S[2]*10+S[3] and S[2]*10+S[3]<=12:
    if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if 1<=S[0]*10+S[1] and S[0]*10+S[1]<=12:
        print('MMYY')
    else:
        print('NA')
s = input()

aa = int(s[0])*10 + int(s[1])
bb = int(s[2])*10 + int(s[3])

if 1 <= aa <= 12 and 1 <= bb <= 12 :
    print("AMBIGUOUS")
elif 1 <= aa <= 12 and bb == 0 :
    print("MMYY")
elif 1 <= aa <= 12 and 13 <= bb :
    print("MMYY")
elif aa == 0 and 1<= bb <= 12 :
    print("YYMM")
elif 13<=aa and 1<=bb<=12 :
    print("YYMM")
else :
    print("NA")
form = input().strip()
m_limit = ["{:0>2}".format(i) for i in range(1, 13)]

f2d, l2d = form[:2], form[2:]
if f2d in m_limit and l2d in m_limit:
    print("AMBIGUOUS")
elif f2d in m_limit:
    print("MMYY")
elif l2d in m_limit:
    print("YYMM")
else:
    print("NA")
s = input()
aa = s[:2]
bb = s[2:]
if 0 < int(aa) < 13 and 0 < int(bb) < 13:
    print('AMBIGUOUS')
elif 0 < int(aa) < 13:
    print('MMYY')
elif 0 < int(bb) < 13:
    print('YYMM')
else:
    print('NA')
S=input()
s=int(S[:2])
t=int(S[2:])
if (s>12 or s==0) and (t>12 or t==0):
    print("NA")
elif s>=1 and s<=12 and (t>12 or t==0):
    print("MMYY")
elif t>=1 and t<=12 and (s>12 or s==0):
    print("YYMM")
else:
    print("AMBIGUOUS")
S=input()
x=int(S[:2])
y=int(S[2:])
if x==0:
    if 0<y<=12:
        print("YYMM")
    else:
        print("NA")
elif 0<x<=12:
    if 0<y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif x>=13:
    if 0<y<=12:
        print("YYMM")
    else:
        print("NA")
# ABC126B

s = int(input())
aa = s // 100
bb = s %  100
if 1 <= aa and aa <= 12:
    if 1 <= bb and bb <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= bb and bb <= 12:
        print('YYMM')
    else:
        print('NA')
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
s=input()
fr=s[0:2]
ba=s[2:4]
if 1<=int(fr)<=12 and 1<=int(ba)<=12:
    ans="AMBIGUOUS"
elif 1<=int(fr)<=12 and (int(ba)<1 or int(ba)>12):
    ans="MMYY"
elif 1<=int(ba)<=12 and (int(fr)<1 or int(fr)>12):
    ans="YYMM"
elif (int(ba)<1 or int(ba)>12) and (int(ba)<1 or int(ba)>12):
    ans="NA"
print(ans)
S=input()

if (int(S[:2])>12 or int(S[:2])==0) and 0<int(S[2:])<=12:
    print("YYMM")
elif 0<int(S[:2])<=12 and (int(S[2:])>12 or int(S[2:])==0):
    print("MMYY")
elif 0<int(S[:2])<=12 and 0<int(S[2:])<=12:
    print("AMBIGUOUS")
else:
    print("NA")
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

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

if __name__ == '__main__':
    main()
def is_yymm(fmt):
    _, month = fmt[:2], fmt[2:]
    if 1 <= int(month) <= 12:
        return True
    else:
        return False


def is_mmyy(fmt):
    month, _ = fmt[:2], fmt[2:]
    if 1 <= int(month) <= 12:
        return True
    else:
        return False


s = input()
if is_mmyy(s) and is_yymm(s):
    print('AMBIGUOUS')
elif is_mmyy(s):
    print('MMYY')
elif is_yymm(s):
    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<=b<=12:
    print('YYMM')
elif 1<=a<=12:
    print('MMYY')
else:
    print('NA')
S=list(input())
F=int(''.join(S[0:2]))
B=int(''.join(S[2:4]))
if 0<F<13 and 0<B<13:
  ans='AMBIGUOUS'
elif F>12 and B>12:
  ans='NA'
elif F>12 and 0<B<13:
  ans='YYMM'
elif B>12 and 0<F<13:
  ans='MMYY'
elif F==0:
  if not 0<B<13:
    ans='NA'
  else:
    ans='YYMM'
elif B==0:
  if not 0<F<13:
    ans='NA'
  else:
    ans='MMYY'
print(ans)
import sys

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


def solve():
    S = input()
    ym1 = int(S[0:2])
    ym2 = int(S[2:4])

    yymm = (1 <= ym2 and ym2 <= 12)
    mmyy = (1 <= ym1 and ym1 <= 12)

    if yymm and mmyy:
        ans = 'AMBIGUOUS'
    elif yymm:
        ans = 'YYMM'
    elif mmyy:
        ans = 'MMYY'
    else:
        ans = 'NA'

    print(ans)


if __name__ == '__main__':
    solve()
s = input()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
if 1<=s1<=12 and 1<=s2<=12:
  print("AMBIGUOUS")
elif 0<=s1<=99 and 1<=s2<=12:
  print('YYMM')
elif 0<=s2<=99 and 1<=s1<=12:
  print('MMYY')
else:
  print('NA')
def f(y, m):
	if y in range(1, 13) and m in range(1, 13):
		return "AMBIGUOUS"
	if m in range(1, 13):
		return "YYMM"
	if y in range(1, 13):
		return "MMYY"
	return "NA"
  
S = input()
y, m = int(S[:2]), int(S[2:])
print(f(y, m))