Problem:
 Score : 200 points    Problem Statement You have a digit sequence S of length 4 . You are wondering which of the following formats S is in:   YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order  MMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order   If S is valid in only YYMM format, print YYMM ; if S is valid in only MMYY format, print MMYY ; if S is valid in both formats, print AMBIGUOUS ; if S is valid in neither format, print NA .      Constraints  S is a digit sequence of length 4 .         Input Input is given from Standard Input in the following format:  S       Output Print the specified string: YYMM , MMYY , AMBIGUOUS or NA .        Sample Input 1 1905      Sample Output 1 YYMM  May XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.       Sample Input 2 0112      Sample Output 2 AMBIGUOUS  Both December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.       Sample Input 3 1700      Sample Output 3 NA  Neither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.

Solution (Python):


def main():
    S = input()
    zenhan = int(S[0] + S[1])
    kouhan = int(S[2] + S[3])

    judgeZenhan = judge12(zenhan)
    judgeKouhan = judge12(kouhan)

    print(judgeFormat(judgeKouhan, judgeZenhan))


def judgeFormat(judgeKouhan, judgeZenhan):
    if judgeZenhan and judgeKouhan:
        return 'AMBIGUOUS'
    elif judgeZenhan and not judgeKouhan:
        return 'MMYY'
    elif not judgeZenhan and judgeKouhan:
        return 'YYMM'
    else:
        return 'NA'


def judge12(num):
    if num < 13 and num > 0:
        return True
    return False


if __name__ == "__main__":
    main()

Solution (Python):
list1 = list(input())

a = int("".join(list1[:2]))
b = int("".join(list1[2:]))

def func(i):
    if 0 < i < 13:
        return True

if func(a):
    if func(b):
        print("AMBIGUOUS")
        exit()
    else:
        print("MMYY")
        exit()
elif func(b):
    print("YYMM")
    exit()

print("NA")

Solution (Python):
s = input()

if 0 < int(s[:2]) < 13 :
    if 0 < int(s[2:]) < 13 :
        print('AMBIGUOUS')
    else :
        print('MMYY')
else :
    if 0 < int(s[2:]) < 13:
        print('YYMM')
    else :
        print('NA')

Solution (Python):
s=input()
s1=int(s[:2])
s2=int(s[2:])
if 0<s1<13 and 0<s2<13:
  print("AMBIGUOUS")
elif (12<s1 or s1==0) and 0<s2<13:
  print("YYMM")
elif (12<s2 or s2==0) and 0<s1<13:
  print("MMYY")
else:
  print("NA")

Solution (Python):
S = input()
m = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
if S[:2] in m and S[2:] in m:
  print("AMBIGUOUS")
elif S[:2] not in m and S[2:] in m:
  print("YYMM")
elif S[:2] in m and S[2:] not in m:
  print("MMYY")
else:
  print("NA")

Solution (Python):
N=list(input())
A=int(''.join(N[0:2]))
B=int(''.join(N[2:4]))

FLG_A = (A>12) | (A==0)
FLG_B = (B>12) | (B==0)


if FLG_A & FLG_B:
    ans='NA'
elif FLG_A & ~FLG_B:
    ans='YYMM'
elif ~FLG_A & FLG_B:
    ans='MMYY'
elif ~FLG_A & ~FLG_B:
    ans='AMBIGUOUS'

print(ans)

Solution (Python):
N=list(input())
A=int(''.join(N[0:2]))
B=int(''.join(N[2:4]))

FLG_A = (A>12) or A==0
FLG_B = (B>12) or B==0


if FLG_A & FLG_B:
    ans='NA'
elif FLG_A & ~FLG_B:
    ans='YYMM'
elif ~FLG_A & FLG_B:
    ans='MMYY'
elif ~FLG_A & ~FLG_B:
    ans='AMBIGUOUS'

print(ans)

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

Solution (Python):
s = input()
a = int(s[:2])
b = int(s[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")

Solution (Python):

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

Solution (Python):
S = input()
a, b = int(S[:2]), int(S[2:])
if (1 <= a <= 12):
    if (1 <= b <= 12):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if (1 <= b <= 12):
        print('YYMM')
    else:
        print('NA')

Solution (Python):
s=input()
a=""
b=""
a=a+s[0]+s[1]
b=b+s[2]+s[3]
acount=0
bcount=0
if a=="00" and int(b)>=13:
  print("NA")
  acount=100
  bcount=100
if b=="00" and int(a)>=13:
  print("NA")
  acount=100
  bcount=100
if b=="00" and a=="00":
  print("NA")
  acount=100
  bcount=100
if int(b)>=13 and int(a)>=13:
  print("NA")
  acount=100
  bcount=100
  
if int(a)>=13 or a=="00":
  acount+=1
if int(b)>=13 or b== "00":
  bcount+=1
if acount+bcount==0:
  print("AMBIGUOUS")
elif acount+bcount== 1:
  if acount==0:
     print("MMYY")
  elif acount==1:
    print("YYMM")

Solution (Python):
S = input()
S1 = int(S[0] + S[1])
S2 = int(S[2] + S[3])

if 0 < S1 <= 12 and 0 < S2 <= 12:
    print('AMBIGUOUS')
elif 0 < S1 <= 12:
    print('MMYY')
elif 0 < S2 <= 12:
    print('YYMM')
else:
    print('NA')

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

Solution (Python):
S = str(input())

X = int(S[:2])
Y = int(S[2:])

if 0< X <= 12 and 0< Y <= 12:
    print('AMBIGUOUS')
elif 0< X <= 12:
    print('MMYY')
elif 0 < Y <= 12:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()
YYMM = True
MMYY = True
if int(S[:2]) >= 13 or S[:2] == "00":
  MMYY = False
if int(S[2:]) >= 13 or S[2:] == "00":
  YYMM = False
if YYMM and MMYY:
  print("AMBIGUOUS")
elif YYMM == True and MMYY == False:
  print("YYMM")
elif MMYY == True and YYMM == False:
  print("MMYY")
else:
  print("NA")

Solution (Python):
S = input()

S1 = int(S[:2])
S2 = int(S[2:4])

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

Solution (Python):
s = input()

ot = int(s[0:2])
tf = int(s[2:4])

if ot > 12 or ot == 0:
	if tf > 12 or tf == 0:
		print("NA")
	else:
		print("YYMM")
elif tf > 12 or tf == 0:
	print("MMYY")
else:
	print("AMBIGUOUS")

Solution (Python):
S=input()
ab=int(S[0]+S[1])
cd=int(S[2]+S[3])
if ab==0:
  if cd==0:
    print('NA')
  elif cd>=1 and cd<=12:
    
    print('YYMM')
  else: 
    print('NA')
elif ab>=1 and ab<=12:
  if cd ==0:
    print('MMYY')
  elif cd>=1 and cd<=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if cd>=1 and cd<=12:
    print('YYMM')
  else:
    print("NA")

Solution (Python):
s=input()
s1=int(s[:2])
s2=int(s[2:4])
if s1>12 :
  if s2>0 :
    if s2<=12 :
      print("YYMM")
    else :
      print("NA")
  else :
    print("NA")
elif s1>0:
  if s2>0 :
    if s2<=12 :
      print("AMBIGUOUS")
    else :
      print("MMYY")
  else :
    print("MMYY")
else :
  if s2>0 :
    if s2<=12 :
      print("YYMM")
    else :
      print("NA")
  else :
    print("NA")

Solution (Python):
S = input()
a = int(S[0] + S[1])
b = int(S[2] + S[3])
if 1<=a<=12:
    if 1<=b<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=b<=12:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
S = input()

if int(S[0:2]) >= 1 and 12 >= int(S[0:2]):
    if int(S[2:4]) >= 1 and 12 >= int(S[2:4]):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if int(S[2:4]) >= 1 and 12 >= int(S[2:4]):
        print('YYMM')
    else:
        print('NA')

Solution (Python):
S = input()

S_01 = int(S[0] + S[1])
S_23 = int(S[2] + S[3])

yymm_flag = False
mmyy_flag = False

if S_01 == 0 and S_23 == 0:
    yymm_flag = False
    mmyy_flag = False
    
if S_01 <= 12 and S_01 >= 1:
    mmyy_flag = True

if S_23 <= 12 and S_23 >= 1:
    yymm_flag = True

if yymm_flag == True and mmyy_flag == True:
    print('AMBIGUOUS')
elif mmyy_flag == True and yymm_flag == False:
    print('MMYY')
elif yymm_flag == True and mmyy_flag == False:
    print('YYMM')
else:
    print('NA')

Solution (Python):
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')

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = int(read())

x = S//100
y = S%100

yymm = (1<=y<=12)
mmyy = (1<=x<=12)

if yymm and mmyy:
    answer = 'AMBIGUOUS'
elif yymm and not(mmyy):
    answer = 'YYMM'
elif mmyy and not(yymm):
    answer = 'MMYY'
else:
    answer = 'NA'
print(answer)

Solution (Python):
s = list(input())
YYMM = 0
MMYY = 0
if 1 <= int(s[2]+s[3]) <= 12:
    YYMM = 1
if 1 <= int(s[0]+s[1]) <= 12:
    MMYY = 1
 
if MMYY == YYMM == 1:
    print("AMBIGUOUS")
elif YYMM == 1:
    print("YYMM")
elif MMYY == 1:
    print("MMYY")
else:
    print("NA")

Solution (Python):
A=int(input())
B=int(A/100)
C=A%100
if 1<=B and B<=12:
 if 1<=C and C<=12:
  print("AMBIGUOUS")
 else:
  print("MMYY")
else:
 if 1<=C and C<=12:
  print("YYMM")
 else:
  print("NA")

Solution (Python):
s=input()
a=int(s[:2])
b=int(s[2:])
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')

Solution (Python):
S=input()

if 0 < int(S[:2]) < 13 and 0 < int(S[2:]) < 13:
    print('AMBIGUOUS')
    exit()

if 0 <= int(S[:2]) and 0 < int(S[2:]) < 13:
    print('YYMM')
    exit()
if 0 < int(S[:2]) < 13 and 0 <= int(S[2:]):
    print('MMYY')
    exit()
else:
    print('NA')

Solution (Python):
S = input()

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

Solution (Python):
s = list(input())
YYMM = 0
MMYY = 0
if 1 <= int(s[2]+s[3]) <= 12:
    YYMM = 1
if 1 <= int(s[0]+s[1]) <= 12:
    MMYY = 1

if MMYY == YYMM == 1:
    print("AMBIGUOUS")
elif YYMM == 1:
    print("YYMM")
elif MMYY == 1:
    print("MMYY")
else:
    print("NA")

Solution (Python):
S=list(input())
a=[S[0],S[1]]
b=[S[2],S[3]]
c=int("".join(a))
d=int("".join(b))
if 0<c<13 and 0<d<13:
  print("AMBIGUOUS")
if 0<c<13 and (d<1 or 12<d):
  print("MMYY")
if (c<1 or 12<c) and 0<d<13:
  print("YYMM")
if (c<1 or 12<c) and (d<1 or 12<d):
  print("NA")

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

Solution (Python):
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')

Solution (Python):
s=input()
l=s[0]+s[1]
m=s[2]+s[3]
month=['01','02','03','04','05','06','07','08','09','10','11','12']
if month.count(l)==1 and month.count(m)==1:
    print('AMBIGUOUS')
elif month.count(l)==1 and month.count(m)==0:
    print('MMYY')
elif month.count(m)==1 and month.count(l)==0:
    print('YYMM')
else:
    print('NA')

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

Solution (Python):
s=input()
s1=s[:2]
s2=s[2:]
print("AMBIGUOUS" if (0<int(s1)<13)and(0<int(s2)<13) else "MMYY" if 0<int(s1)<13 else "YYMM" if 0<int(s2)<13 else "NA")

Solution (Python):
from sys import stdin

s = stdin.readline().rstrip()

mae = s[:2]
ato = s[2:]

def syoukyo(i):
    if i[0] == 0:
        i = i[1]
    return int(i)

mae = syoukyo(mae)
ato = syoukyo(ato)

if (mae > 12 or mae == 0) and 0 <ato < 13:
    print("YYMM")
elif 0 <mae < 13 and( ato > 12 or ato == 0):
    print("MMYY")
elif 0 <mae < 13 and 0 <ato < 13:
    print("AMBIGUOUS")
else:
    print("NA")

Solution (Python):

s = list(input())
yymm = False
mmyy = False


if int("".join(s[0:2])) in range(1,13):
    mmyy = True
if int("".join(s[2:4])) in range(1,13):
    yymm = True



if yymm:
    if mmyy:
       print("AMBIGUOUS") 
    else:
        print("YYMM")
elif mmyy:
    print("MMYY")
else:
    print("NA")

Solution (Python):
def main(f, e):
    if 0 <f <13:
        if 0<e<13:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if 0<e<13:
            print("YYMM")
        else:
            print("NA")
if __name__ == "__main__":
    S = input()

    a = int(S[:2])
    b = int(S[2:])
    main(a, b)

Solution (Python):
s = input()

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


if((0 <= a <= 99) & (1 <= b <= 12)):
    if((0 <= b <= 99) & (1 <= a <= 12)):
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if((0 <= b <= 99) & (1 <= a <= 12)):
        print("MMYY")
    else:
        print("NA")

Solution (Python):
s=str(input())

s_1=int(s[0]+s[1])
s_2=int(s[2]+s[3])



if (s_1>=1) & (s_1<=12) & (s_2>=1) & (s_2<=12):
	print("AMBIGUOUS")
	
elif ((s_1>=1) & (s_1<=12)) & ((s_2==0) | (s_2>=13)):
	print("MMYY")

elif ((s_1==0) | (s_1>=13)) & ((s_2>=1) & (s_2<=12)):
	print("YYMM")
	
else:
	print("NA")

Solution (Python):
S = input()
a = int(S[:2])
b = int(S[2:])
is_a_Y = is_b_Y = False

if 1 <= a <= 12:
    is_a_Y = True
if 1 <= b <= 12:
    is_b_Y = True

if is_a_Y and is_b_Y:
    print('AMBIGUOUS')
elif is_a_Y and not is_b_Y:
    print('MMYY')
elif not is_a_Y and is_b_Y:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()
a = int(S[:2])
b = int(S[2:])

if 1 <= a and a <= 12 and 1 <= b and b <= 12:
    print("AMBIGUOUS")
elif 1 <= a and a <= 12 and (b > 12 or b < 1):
    print("MMYY")
elif (a > 12 or a < 1) and 1 <= b and b <= 12:
    print("YYMM")
else:
    print("NA")

Solution (Python):
S=input()
s1=int(S[0:2])
s2=int(S[2:5])

if 1<=s1<=12:
    print("AMBIGUOUS" if 1<=s2<=12 else "MMYY")
else:
    print("YYMM" if 1<=s2<=12 else "NA")

Solution (Python):
s = list(input())
left = int( s[0]+s[1] )
right = int( s[2]+s[3] )

if 1 <= left <= 12:
    if 1 <= right <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= right <= 12:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
s = list(input())
left = int( s[0]+s[1] )
right = int( s[2]+s[3] )

if 1 <= left <= 12:
    if 1 <= right <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= right <= 12:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
def mmok(i):
    return 1 <= i <= 12


S = input()
h = int(S[:2])
l = int(S[2:])

if mmok(h):
    if mmok(l):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if mmok(l):
        print('YYMM')
    else:
        print('NA')

Solution (Python):
S = input()
S_first_half = int(S[0:2])
S_last_half = int(S[2:5])

if 1 <= S_first_half <= 12:
    if 1 <= S_last_half <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1 <= S_last_half <= 12:
    print("YYMM")
else:
    print("NA")

Solution (Python):
def solve():
    s = input()
    first_harf = int(s[:2])
    second_harf = int(s[2:])

    if first_harf == 0 or first_harf > 12:
        if second_harf == 0 or second_harf > 12:
            print('NA')
        else:
            print('YYMM')
    else:
        if second_harf == 0 or second_harf > 12:
            print('MMYY')
        else:
            print('AMBIGUOUS')

if __name__ == '__main__':
    solve()

Solution (Python):
s = int(input())
judge = '0'

k = s % 100
z = (s - k)/100

if 0 < z <= 12:
    judge = '1'
if 0 < k <= 12:
    judge += '1'
else:
    judge += '0'

if judge == '00':
    print('NA')
elif judge == '01':
    print('YYMM')
elif judge == '10':
    print('MMYY')
else:
    print('AMBIGUOUS')

Solution (Python):
s = input()
if s[:2] == "00" and s[2:] == "00":
  print("NA")
  exit()
elif s[:2] == "00" and int(s[2:]) > 12:
  print("NA")
  exit()
elif s[:2] == "00" and int(s[2:]) <= 12:
  print("YYMM")
  exit()
elif int(s[:2]) > 12 and s[2:] == "00":
  print("NA")
  exit()
elif int(s[:2]) <= 12 and s[2:] == "00":
  print("MMYY")
  exit()
if int(s[:2]) > 12 and int(s[2:]) > 12:
  print("NA")
  exit()
elif int(s[:2]) <= 12 and int(s[2:]) <= 12:
  print("AMBIGUOUS")
  exit()
elif int(s[:2]) <= 12:
  print("MMYY")
  exit()
elif int(s[2:]) <= 12:
  print("YYMM")
  exit()

Solution (Python):
S = input()
p = int(S[:2])
s = int(S[2:])

if (p > 12 or p == 0) and (s <= 12 and s > 0):
  print("YYMM")
elif (p > 0 and p <= 12) and (s > 12 or s == 0):
  print("MMYY")
elif p < 13 and s < 13 and p > 0 and s > 0:
  print("AMBIGUOUS")
else:
  print("NA")

Solution (Python):
s=list(input())
a=int(''.join(s[:2]))
b=int(''.join(s[2:]))
if 0<a and a<=12 and 0<b and b<=12:
    print("AMBIGUOUS")
elif((a==0 or a>12) and 0<b and b<=12):
    print("YYMM")
elif 0<a and a<=12 and (b==0 or b>12):
    print("MMYY")
else:
    print("NA")

Solution (Python):
S=int(input())
a=S//100;b=S%100
if 1<=a<=12:
    if 1<=b<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=b<=12:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
S=input()
pre=int(S[:2])
post=int(S[2:])
if 1<=pre<=12:
    if 1<=post<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=post<=12:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
s = input()
print('AMBIGUOUS' if 1 <= int(s[0]+s[1]) <= 12 and 1 <= int(s[2]+s[3]) <= 12 else 'YYMM' if 0 <= int(s[0]+s[1]) <= 99 and 1 <= int(s[2] + s[3]) <= 12 else 'MMYY' if  0 <= int(s[2]+s[3]) <= 99 and 1 <= int(s[0] + s[1]) <= 12 else 'NA')

Solution (Python):
s=input()
if 0 < int(s[:2]) < 13:
  if 0 < int(s[2:]) < 13:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0 < int(s[2:]) < 13:
    print('YYMM')
  else:
    print('NA')

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    yy = int(s[:2])
    mm = int(s[2:])
    if 1 <= mm <= 12 and 1 <= yy <= 12:
        print("AMBIGUOUS")
    elif 1 <= mm <= 12:
        print("YYMM")
    elif 1 <= yy <= 12:
        print("MMYY")
    else:
        print("NA")


if __name__ == '__main__':
    slove()

Solution (Python):
s = input()
s = [int(s[:2]), int(s[2:])]

ans = 0
if s[0] < 1 or s[0] > 12:
    ans += 1
if s[1] < 1 or s[1] > 12:
    ans += 2

p = ['AMBIGUOUS', 'YYMM', 'MMYY', 'NA']
print(p[ans])

Solution (Python):
S = input()
S1 = int(S[:2])
S2 = int(S[2:])
if (S1==0 or 13<=S1) and (S2==0 or 13<=S2):
    print("NA")
    exit()
if 1 <= S1 <=12 and 1<=S2<=12:
    print("AMBIGUOUS")
    exit()
if 1 <= S1 <=12:
    print("MMYY")
    exit()
else:
    print("YYMM")

Solution (Python):
x=int(input())
if x%100<13 and x%100>0:
  if x//100<13 and x//100>0:
    print("AMBIGUOUS")
  else:
    print("YYMM")
else:
  if x//100<13 and x//100>0:
    print("MMYY")
  else:
    print("NA")

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = input().rstrip()
    flag1 = True if 0 < int(''.join(S[:2])) <= 12 else False
    flag2 = True if 0 < int(''.join(S[2:])) <= 12 else False
    
    if flag1 and flag2: print('AMBIGUOUS')
    elif flag1 and not flag2: print('MMYY')
    elif not flag1 and flag2: print('YYMM')
    else: print('NA')

if __name__ == '__main__':
    main()

Solution (Python):
s=input()
u=int(s[0]+s[1])
d=int(s[2]+s[3])
if 0<u<=12 and 0<d<=12:
  print('AMBIGUOUS')
elif 0<u<=12 and (d>12 or d==0):
  print('MMYY')
elif (u>12 or u==0) and 0<d<=12:
  print('YYMM')
else:
  print('NA')

Solution (Python):
S = input()

head = S[:2]
tail = S[2:]

is_yymm = True
is_mmyy = True

if head == "00" or head >= "13":
    is_mmyy = False

if tail == "00" or tail >= "13":
    is_yymm = False

if is_yymm and is_mmyy:
    print("AMBIGUOUS")
elif is_yymm:
    print("YYMM")
elif is_mmyy:
    print("MMYY")
else:
    print("NA")

Solution (Python):
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 b >=13):
         print("MMYY")
elif 1 <= b <=12 and (a == 0 or a >=13):
         print("YYMM")
else:
         print("NA")

Solution (Python):
S = input()
A, B = int(S[:2]), int(S[2:])
MMp = lambda x: 1 if x<=12 and x!=0 else 0
print(["NA","YYMM","MMYY","AMBIGUOUS"][MMp(A)*2+MMp(B)])

Solution (Python):
S = list(input())
N = [int(i) for i in S]
A = N[0]*10+N[1] in range(1,13)
B = N[2]*10+N[3] in range(1,13)
if(A):
  print("AMBIGUOUS") if(B) else print("MMYY")
elif(B):
  print("YYMM")
else:
  print("NA")

Solution (Python):
s = input()
before = s[0:2]
after = s[2:4]

b = 0<int(before)<13
a = 0<int(after)<13

if a and b:
    print('AMBIGUOUS')
elif a and not b:
    print('YYMM')
elif b and not a:
    print('MMYY')
else:
    print('NA')

Solution (Python):


s = raw_input()

first = int(s[:2])
second = int(s[2:])

frstMM = first <= 12 and first > 0
scndMM = second <= 12 and second > 0

if frstMM and scndMM:
    print "AMBIGUOUS"
elif frstMM:
    print "MMYY"
elif scndMM:
    print "YYMM"
else:
    print "NA"

Solution (Python):
s=str(input())

s1,s2 = int(s[:2]),int(s[2:])

flag1,flag2 = False,False

if   1 <= s2 <= 12:
      flag1 = True

if 1 <= s1 <= 12:
      flag2 = True

if flag1 == True:
      if flag2 == True:
            print("AMBIGUOUS")
      else:
            print("YYMM")
elif flag2 == True:
      print("MMYY")
else:
      print("NA")

Solution (Python):
s = input()

flagym = 0
flagmy = 0

if 0<int(s[0:2])<= 12:
    flagmy = 1 
if 0<int(s[2:])<= 12:
    flagym = 1

if flagym ==1:
    if flagmy == 1:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if flagmy == 1:
        print("MMYY")
    else:
        print("NA")

Solution (Python):
S = list(input())
judge_yymm = 0
judge_mmyy= 0

if(1<=int(S[2]+S[3])<=12): judge_yymm = 1
if(1<=int(S[0]+S[1])<=12): judge_mmyy = 1
  
if((judge_yymm==1)and(judge_mmyy==1)): print('AMBIGUOUS')
elif((judge_yymm==1)and(judge_mmyy==0)): print('YYMM')
elif((judge_yymm==0)and(judge_mmyy==1)): print('MMYY')
else: print('NA')

Solution (Python):
S = input()

YYMM_yy = int(S[0]) * 10 + int(S[1])
YYMM_mm = int(S[2]) * 10 + int(S[3])
YYMM = False
MMYY = False
AM = False
NA = False
if YYMM_yy > 12:
    YYMM = True
elif YYMM_mm > 12:
    MMYY = True
elif YYMM_yy != 0 and YYMM_mm != 0:
    AM = True
if YYMM_yy == 0:
    YYMM = True
elif YYMM_mm == 0:
    MMYY = True
if YYMM_yy == 0 and YYMM_mm > 12:
    NA = True
elif YYMM_mm == 0 and YYMM_yy > 12:
    NA = True
elif YYMM_mm == 0 and YYMM_yy == 0:
    NA = True
elif YYMM_mm > 12 and YYMM_yy > 12:
    NA = True

if NA:
    print('NA')
elif AM:
    print('AMBIGUOUS')
elif YYMM:
    print('YYMM')
elif MMYY:
    print('MMYY')

Solution (Python):
s=input()
a = int(s[0:2])
b = int(s[2:4])

def isM(x: int):
  if 1 <= x <= 12:
    return True
  else:
    return False

if isM(a) and isM(b):
  print("AMBIGUOUS")
elif isM(a) and not isM(b):
  print("MMYY")
elif not isM(a) and isM(b):
  print("YYMM")
elif not isM(a) and not isM(b):
  print("NA")

Solution (Python):
s = input()
s_header = int(s[0:2])
s_footer = int(s[2:4])




if s_header >=1 and s_header <=12 and s_footer >= 1 and s_footer <= 12 :
  print("AMBIGUOUS")
elif s_header >= 0 and s_footer >=1 and s_footer <=12:
  print("YYMM")
elif s_header >=1 and s_header <=12 and s_footer >= 0:
  print("MMYY")
else:
  print("NA")

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
s = input()

mmyy = 1 <= int(s[:2]) <= 12
yymm = 1 <= int(s[2:]) <= 12

if yymm and mmyy:
    print("AMBIGUOUS")
elif yymm:
    print("YYMM")
elif mmyy:
    print("MMYY")
else:
    print("NA")

Solution (Python):
s = input()

if 0 < int(s[2:]) < 13 and 0 < int(s[:2]) < 13:
    print('AMBIGUOUS')
elif 0 < int(s[2:]) < 13:
    print('YYMM')
elif 0 < int(s[:2]) < 13:
    print('MMYY')
else:
    print('NA')

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    S = input()
    pre = int(S[0:2])
    suf = int(S[2:4])

    if pre >= 1 and pre <= 12 and suf >= 1 and suf <= 12:
        print('AMBIGUOUS')
        exit()
    elif pre >= 1 and pre <= 12:
        print('MMYY')
        exit()
    elif suf >= 1 and suf <= 12:
        print('YYMM')
        exit()
    else:
        print('NA')



if __name__ == '__main__':
    main()

Solution (Python):
S = input()
left = S[:2]
right = S[2:]

month = [str(m).zfill(2) for m in range(1, 13)]
year = [str(y).zfill(2) for y in range(0, 100)]

if (left in year and right in year) and (left in month and right in month):
    print("AMBIGUOUS")
elif left in month and right in year:
    print("MMYY")
elif left in year and right in month:
    print("YYMM")
else:
    print("NA")

Solution (Python):
n = input()
if 1 <= int(n[2:]) <= 12 and 1 <= int(n[:2]) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(n[:2]) <= 12:
    print('MMYY')
elif 1 <= int(n[2:]) <= 12:
    print('YYMM')
else:
    print('NA')

Solution (Python):
n=input()
if 1<=int(n[:2])<=12 and 1<=int(n[2:])<=12:
  print("AMBIGUOUS")
elif 1<=int(n[:2])<=12:
  print("MMYY")
elif 1<=int(n[2:])<=12:
  print("YYMM")
else:
  print("NA")

Solution (Python):
s=input()
a=int(s[0:2])
b=int(s[2:4])
ans=0
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')

Solution (Python):



S = input()


is_YYMM = False
is_MMYY = False

if '00' <= S[:2] and ('01' <= S[2:] and S[2:] <= '12'):
    is_YYMM = True
if ('01' <= S[:2] and S[:2] <= '12') and '00' <= S[2:]:
    is_MMYY = True


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

Solution (Python):
s = list(input())
def month(i):
  if 1 <= int(i) <=12:
    return True
  else:
    return False
a = month("".join(s[0:2]))
b = month("".join(s[2:4]))
if a and b:
  print('AMBIGUOUS')
elif not a and b:
  print('YYMM')
elif a and not b:
  print('MMYY')
else:
  print('NA')

Solution (Python):
S = input()
s1 = int(S[:2])
s2 = int(S[2:])

if 1 <= s1 <= 12:
    if 1 <= s2 <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 1 <= s2 <= 12:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()
if 13 <= int(S[:2]) and int(S[2:]) == 0:
    print('NA')
elif 0 == int(S[:2]) and int(S[2:]) >= 13:
    print('NA')
elif int(S[:2]) >= 13 and int(S[2:]) >= 13:
    print('NA')
elif int(S[:2]) == 0 and int(S[2:]) == 0:
    print('NA')
elif 13 <= int(S[:2]) or 0 == int(S[:2]) and int(S[2:]) <= 12:
    print('YYMM')
elif 12 >= int(S[:2]) and int(S[2:]) >= 13 or int(S[2:]) == 0:
    print('MMYY')
else:
    print('AMBIGUOUS')

Solution (Python):
S=input()
if S[0]=='0' and S[1]!='0':
    if S[2]=='0' and S[3]!='0':
        print('AMBIGUOUS')
    elif S[2]=='1' and (S[3]=='0' or S[3]=='1' or S[3]=='2'):
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif S[0]=='1' and(S[1]=='0' or S[1]=='1' or S[1]=='2'):
    if S[2]=='0' and S[3]!='0':
        print('AMBIGUOUS')
    elif S[2]=='1' and (S[3]=='0' or S[3]=='1' or S[3]=='2'):
        print('AMBIGUOUS')
    else:
        print('MMYY')
 
else:
    if S[2]=='0' and S[3]!='0':
        print('YYMM')
    elif S[2]=='1' and (S[3]=='0' or S[3]=='1' or S[3]=='2'):
        print('YYMM')
    else:
        print('NA')

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

Solution (Python):
S=int(input())

A=int(S/100)
B=int(S%100)

if 1<=A and A<=12:
    if 1<=B and B<=12:
        print('AMBIGUOUS')
    else :
        print('MMYY')
else :
    if 1<=B and B<=12:
        print('YYMM')
    elif B>=13:
        print('NA')
    elif B==0:
        print('NA')

Solution (Python):
s = input()
left = s[:2]
right = s[2:]

if (0 < int(left) < 13) and (0 < int(right) < 13):
  print("AMBIGUOUS")
elif (0 < int(left) < 13) and ((int(right) >= 13) or (int(right) == 0)):
  print("MMYY")
elif ((int(left) >= 13) or (int(left) == 0)) and (0 < int(right) < 13):
  print("YYMM")
else:
  print("NA")

Solution (Python):
a,b,c,d=input()
ab=int(a)*10+int(b)
cd=int(c)*10+int(d)
if 1<=ab<=12:
  if 1<=cd<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=cd<=12:
    print("YYMM")
  else:
    print("NA")

Solution (Python):
X=input()
YM=0
MY=0
F=int(X[0] + X[1])
B=int(X[2] + X[3])
if 0<F<=12 :
    MY += 1
else:
    pass

if 0<B<=12 :
    YM += 1
else:
    pass

if YM == 1 and MY == 1 :
    print("AMBIGUOUS")
elif YM == 1 and MY == 0 :
    print("YYMM")
elif YM == 0 and MY == 1 :
    print("MMYY")
else :
    print("NA")

Solution (Python):
s = input()
f = int(s[:2])
b = int(s[2:])
if 1 <= f <= 12:
  if 1 <= b <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= b <= 12:
    print('YYMM')
  else:
    print('NA')

Solution (Python):
s = input()
a = int(s[0:2])
b = int(s[2:4])

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

Solution (Python):
s = list(input())
a = int(s[0]+s[1])
b = int(s[2]+s[3])

if a<=12 and b<=12 and a>0 and b>0:
  print("AMBIGUOUS")
elif b<=12 and b>0:
  print("YYMM")
elif a<=12 and a>0:
  print("MMYY")
else:
  print("NA")

Solution (Python):
S = list(input())
for i in range(len(S)):
    S[i] = int(S[i])
A = 10*S[0] + S[1]
B = 10*S[2] + S[3]
if (A == 0 or A >= 13) and (B == 0 or B >= 13):
    print("NA")
elif A == 0 or A >= 13:
    print("YYMM")
elif B == 0 or B >= 13:
    print("MMYY")
else:
    print("AMBIGUOUS")

Solution (Python):
n = int(input())
zen = int(n // 100)
go = int(n % 100)
if zen and zen <= 12 and go and go <= 12:
  print("AMBIGUOUS")
elif zen and zen <= 12:
  print("MMYY")
elif go and go <= 12:
  print("YYMM")
else:
  print("NA")

Solution (Python):
s=input()
word=list(s)
flaga=0
flagb=0
if (s[0]=='0' and 1<=int(s[1])<=9) or (s[0]=='1' and 0<=int(s[1])<=2):
  flaga+=1
if (s[2]=='0' and 1<=int(s[3])<=9) or (s[2]=='1' and 0<=int(s[3])<=2):
  flagb+=1

if flaga==1 and flagb==1:
  print('AMBIGUOUS')
elif flaga==0 and flagb==1:
  print('YYMM')
elif flaga==1 and flagb==0:
  print('MMYY')
elif flaga==0 and flagb==0:
  print('NA')