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):


str = list(raw_input())
f = int(str[0]+str[1])
l = int(str[2]+str[3])

if(f > 0 and 13 > f):
    if(l == 0):
        ans = "MMYY"
    if(l > 0 and 13 > l):
        ans = "AMBIGUOUS"
    if(l >= 13):
        ans= "MMYY"
elif(f == 0):
    if(l == 0):
        ans = "NA"
    if(l > 0 and 13> l):
        ans = "YYMM"
    if(l >= 13):
        ans= "NA"
elif(f>=13):
    if(l == 0):
        ans = "NA"
    if(l > 0 and 13> l):
        ans = "YYMM"
    if(l >= 13):
        ans= "NA"
print ans

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

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

Solution (Python):
S = list(input())
s1 = [S[0],S[1]]
s2 = [S[2],S[3]]
s1 = int("".join(s1))
s2 = int("".join(s2))

if s1 >0 and s1 <13 and s2>0 and s2 <13:
    print("AMBIGUOUS")

elif s2 > 0 and s2 < 13:
    print("YYMM")

elif s1 < 13 and s1 > 0:
    print("MMYY")

else:
    print("NA")

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

a = n[0:2]
b = n[2:]

c = int(a)
d = int(b)
yymm = False
mmyy = False
ambiguous = False
na = False

if (c < 1) or (12 < c):
    if (d < 1) or (12 < d):
        na = True

if (1 <= c) and (c <= 12):
    if (d < 1) or (12 < d):
        mmyy = True

if (1 <= d) and (d <= 12):
    if (c < 1) or (12 < c):
        yymm = True

if na == False and mmyy == False and yymm == False:
    ambiguous = True

if na == True:
    print("NA")
if mmyy == True:
    print("MMYY")
if yymm == True:
    print("YYMM")
if ambiguous == True:
    print("AMBIGUOUS")

Solution (Python):




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

if __name__ == '__main__':
	import sys
	sys.exit(main())

Solution (Python):




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

if __name__ == '__main__':
	import sys
	sys.exit(main())

Solution (Python):
YYMM=0
MMYY=0

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

if int(a)<=12 and 0< int(a):
    MMYY =1
if int(b)<=12 and 0< int(b):
    YYMM =1

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

Solution (Python):
S = input()

F_NA = 0
F_Y = 1
F_M = 2
F_YM = 3

s = [0, 0]
s[0] = int(S[:2])
s[1] = int(S[2:])

flg = [0, 0]
for i in range(2):
    if s[i] >= 1 and s[i] <=12:
        flg[i] = F_YM
    elif s[i] == 0 or s[i] > 12:
        flg[i] = F_Y
    else:
        print("NA")
        exit()

if flg[0] == F_YM:
    if flg[1] == F_YM:
        print("AMBIGUOUS")
    else: 
        print("MMYY")
else: 
    if flg[1] == F_YM:
        print("YYMM")
    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=list(input())
ss=s[:2]
sss=s[2:]
x=int("".join(ss))
y=int("".join(sss))

if 1<=x<=12 and 1<=y<=12:
    print("AMBIGUOUS")
elif 1<=x<=12 :
    print("MMYY")
elif 1<=y<=12:
    print("YYMM")
else:
    print("NA")

Solution (Python):
n = int(input()[:4])
a = n//100
b = n%100
if 0<a<=12 and 0<b<=12:
    print('AMBIGUOUS')
elif 1<=a<=12 and (b>=13 or b==0):
    print('MMYY')
elif 1<=b<=12 and (13<=a or a==0):
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()
S = [S[i: i+2] for i in range(0, len(S), 2) ]

L, R = int(S[0]), int(S[1])


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')

Solution (Python):
S = input()

E1 = int(S[:2])
E2 = int(S[2:])

if E1 >= 1 and E1 <= 12 and E2 >= 1 and E2 <= 12:
  print('AMBIGUOUS')
elif E1 >= 1 and E1 <= 12:
  print('MMYY')
elif E2 >= 1 and E2 <= 12:
  print('YYMM')
else:
  print('NA')

Solution (Python):
S=int(input())
if (S%100>12 and 0<S//100<=12) or (0<S//100<=12 and S%100==0):
    print('MMYY')
elif (S//100>12 and 0<S%100<=12) or (S//100==0 and 0<S%100<=12):
    print('YYMM')
elif 0<S%100<=12 and 0<S//100<=12:
    print('AMBIGUOUS')
else:
    print('NA')

Solution (Python):
S = input()

S12 = int(S[:2])
S34 = int(S[2:])





flags = [0,0,0,0]

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

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

if 1<=b<=12:
    judge[0] = 1

if 1<=a<=12:
    judge[1] = 1

if sum(judge) == 2:
    print("AMBIGUOUS")
elif sum(judge) == 0:
    print("NA")
elif judge[0] == 1:
    print("YYMM")
else:
    print("MMYY")

Solution (Python):


''' 
------------------------
author : iiou16
------------------------
'''

def main():
    S = input()

    aa = int(S[:2])
    bb = int(S[2:])

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


if __name__ == '__main__':
    main()

Solution (Python):


str = list(raw_input())
f = int(str[0]+str[1])
l = int(str[2]+str[3])

if(f > 0 and 13 > f):
    if(l == 0):
        ans = "MMYY"
    if(l > 0 and 13 > l):
        ans = "AMBIGUOUS"
    if(l >= 13):
        ans= "MMYY"
elif(f == 0):
    if(l == 0):
        ans = "NA"
    if(l > 0 and 13> l):
        ans = "YYMM"
    if(l >= 13):
        ans= "NA"
elif(f>=13):
    if(l == 0):
        ans = "NA"
    if(l > 0 and 13> l):
        ans = "YYMM"
    if(l >= 13):
        ans= "NA"
print ans

Solution (Python):




def f(S):
    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")

f(input())

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

front = int(S[:2])
back = int(S[2:4])

if (front == 0 or front > 12) and back > 0 and back <= 12:
    print('YYMM')
elif front <= 12 and front > 0 and (back == 0 or back > 12):
    print('MMYY')
elif (front <= 12 and front > 0) and (back > 0 and back <= 12):
    print('AMBIGUOUS')
else:
    print('NA')

Solution (Python):
S = input()
X = int(S[0:2])
Y = int(S[2:4])

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

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

Solution (Python):
X = input()
X_1=int(X[:2])
X_2=int(X[2:])
flag_1=(0 <= X_1 <=99 and 1 <= X_2 <= 12)
flag_2=(0 <= X_2 <=99 and 1 <= X_1 <= 12)
if flag_1 and flag_2:
    print("AMBIGUOUS")
elif flag_1:
    print("YYMM")
elif flag_2:
    print("MMYY")
else:
    print("NA")

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

Solution (Python):
import numpy as np
import fractions

S = input()
F = int(S[0:2])
E = int(S[2:4])

if(0 < F and F < 13 ):
    if(0 < E and E<13):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if(0 < E and E < 13):
        print("YYMM")
    else:
        print("NA")

Solution (Python):
def isY(num):
    return True

def isM(num):
    if num <= 12 and num >= 1:
        return True

    return False

def isYYMM(first, second):
    return (isY(first) and isM(second))

def isMMYY(first, second):
    return (isM(first) and isY(second))

line = input()
first = int(line[:2])
second = int(line[2:])

ans = "NA"

if (not isMMYY(first, second)) and isYYMM(first, second):
    ans = "YYMM"

if isMMYY(first, second) and (not isYYMM(first, second)):
    ans = "MMYY"

if isMMYY(first, second) and isYYMM(first, second):
    ans = "AMBIGUOUS"

        
print(ans)

Solution (Python):
s = input()
a, b = int(s[:2]), 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):
import sys
input = sys.stdin.readline
s = input()
s1 = s[:2]
s2 = s[2:]
if 1 <= int(s1) <= 12 and 1 <= int(s2) <= 12:
    print("AMBIGUOUS")
elif (not 1 <= int(s1) <= 12) and 1 <= int(s2) <= 12:
    print("YYMM")
elif 1 <= int(s1) <= 12 and (not 1 <= int(s2) <= 12):
    print("MMYY")
else:
    print('NA')

Solution (Python):
S = int(input())
A = S//100
B = S-(A*100)
if B ==0 or B >= 13:
    if 1<= A <=12:    
        print("MMYY")
    else:
        print("NA")
elif 1<= B <=12:
    if 1<= A <=12:
        print("AMBIGUOUS")
    elif A >= 13:
        print("YYMM")
    elif A == 0:      
        print("YYMM")
    else:
        print("NA")
else:
    print("NA")

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


s1 = int(''.join(S[0:2]))
s2 = int(''.join(S[2:4]))



stmp1=""
if s1 <=12 and s1 > 0:
    stmp1='MM'
elif (s1 > 0):
    stmp1='YY'
else:
    stmp1='NA'

stmp2=""
if s2 <=12 and s2 > 0:
    stmp2='MM'
elif (s2 > 0):
    stmp2='YY'
else:
    stmp2='NA'

if((stmp1=='NA' and not (stmp2=='MM')) or (stmp2=='NA' and not (stmp1=='MM')))or(stmp1=='YY' and stmp2=='YY'):
    print('NA')
elif(stmp1=='MM' and stmp2=='MM'):
    print('AMBIGUOUS')
elif(stmp1=='NA'):
    print('YY'+stmp2)
elif(stmp2=='NA'):
    print(stmp1+'YY')
else:
    print(stmp1+stmp2)

Solution (Python):
S = input()

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

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

Solution (Python):
S = input()

yymm = False
mmyy = False


if 0 <= int(S[2:]):
    if 1 <= int(S[:2]) and int(S[:2]) <= 12:
        mmyy = True


if 1 <= int(S[2:]) and int(S[2:]) <= 12:
    if 0 <= int(S[:2]):
        yymm = True

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

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


S12 = int(S_list[0]+S_list[1])
S34 = int(S_list[2]+S_list[3])

flagYYMM = 0
flagMMYY = 0

if 1 <= S34 <= 12:
    flagYYMM = 1

if 1 <= S12 <= 12:
    flagMMYY = 1

if S12 > 13 and S34 == 00:
    flagMMYY = 0

if S34 > 13 and S12 == 00:
    flagYYMM = 0

if flagYYMM == 1 and flagMMYY == 1:
    print("AMBIGUOUS")

elif flagYYMM == 1:
    print("YYMM")

elif flagMMYY == 1:
    print("MMYY")

else:
    print("NA")

Solution (Python):
s=input()
if 10*int(s[0])+int(s[1])<=12 and int(s[0])+int(s[1])!=0:
  if 10*int(s[2])+int(s[3])<=12 and int(s[2])+int(s[3])!=0:
    print("AMBIGUOUS")
  else:
    print("MMYY")
if 10*int(s[0])+int(s[1])>=13 or int(s[0])+int(s[1])==0:
  if 10*int(s[2])+int(s[3])<=12 and int(s[2])+int(s[3])!=0:
    print("YYMM")
  else:
    print("NA")

Solution (Python):
i = list(input())
yy = int(i[0] + i[1])
mm = int(i[2] + i[3])
 
if ((yy > 12) or (yy == 0))  and (0 < mm <= 12):
    print("YYMM")
elif (0 < yy <= 12) and ((mm > 12) or (mm == 0)):
    print("MMYY")
elif (0 < yy <= 12) and (0 < mm <= 12):
    print("AMBIGUOUS")
else:
    print("NA")

Solution (Python):
import math

S = int(input())


YYMM_flag = 0
MMYY_flag = 0

former = math.floor(S / 1000) * 10
S = S % 1000
former += math.floor(S / 100)

S = S % 100
latter = S


if(1 <= former and former <= 12):
    MMYY_flag = 1

if(1 <= latter and latter <= 12):
    YYMM_flag = 1

if(YYMM_flag == 1):
    if(MMYY_flag == 1):
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if(MMYY_flag == 1):
        print('MMYY')
    else:
        print('NA')

Solution (Python):

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

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

Solution (Python):
String=input()
String=list(String)
String=[(String[i:i+2]) for i in range(0, len(String),2)]
String[0]="".join(String[0])
String[1]="".join(String[1])
String[0]=int(String[0])
String[1]=int(String[1])
if(String[0]>0 and String[0]<=12and String[1]>0 and String[1]<=12):
    print("AMBIGUOUS")
elif(String[0]==String[1]==0 or String[0]>12 and String[0]!=0 and String[1]>12 and String[1]!=0):
    print("NA")
elif(String[1]>0 and String[1]<13):
    print("YYMM")
elif(String[0]>0 and String[0]<13):
    print("MMYY")
elif(String[0]==0 and String[1]>12):
    print("NA")
else:
    print("NA")

Solution (Python):
s = input()

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

def check(s1, s2):
    if 1 <= s1 <= 12 and 1 <= s2 <= 12:
        return 'AMBIGUOUS'
    if 1 <= s1 <= 12:
        return 'MMYY'
    if 1 <= s2 <= 12:
        return 'YYMM'
    return 'NA'

print(check(s1, s2))

Solution (Python):
def sol(inp=input):
    s=inp()
    u=int(s[:2])
    l=int(s[2:])
    u_is_m=1<=u and u<=12
    l_is_m=1<=l and l<=12
    if u_is_m and l_is_m:
        return 'AMBIGUOUS'
    if u_is_m and not l_is_m:
        return 'MMYY'
    if not u_is_m and l_is_m:
        return 'YYMM'
    return 'NA'
print(sol())

Solution (Python):
S = input()
F = int(S[:2])
B = int(S[2:])

if 1 <= F <= 12:
    if 1 <= B <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if 1 <= B <= 12:
        ans = "YYMM"
    else:
        ans = "NA"
        
print(ans)

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

if '01' <= S1 and S1 <= '12':
    
    
    if '01' <= S2 and S2 <= '12':
        print('AMBIGUOUS')
        
    
    else:
        print('MMYY')
        

elif '01' <= S2 and S2 <= '12':
    print('YYMM')


else:
    print('NA')

Solution (Python):
s=int(input())
a=s//100
b=s%100
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")

Solution (Python):
s = input().strip()

bs = int(s[:2])
cs = int(s[2:])


if bs <=12 and cs <= 12 and 0<bs and 0<cs:
    print("AMBIGUOUS")
elif (bs==0 or bs > 12) and (cs > 12 or cs ==0):
    print("NA")
elif bs <= 12 and 0 < bs:
    print("MMYY")
elif cs <= 12 and 0 < cs:
    print("YYMM")

Solution (Python):
S = input()
fast = int(S[0:2])
end = int(S[2:4])

if 0 < fast < 13 and 0 < end < 13:
  print('AMBIGUOUS')
elif 0 <= fast and 0 < end < 13:
  print('YYMM')
elif 0 < fast < 13 and 0 <= end:
  print('MMYY')
else:
  print('NA')

Solution (Python):
S = input()
a = int(S[0:2])
b = int(S[2:4])
LIST = [False,False]

if 1 <= b <= 12 and a >= 0:
    LIST[0] = True 
if 1 <= a <= 12 and b >= 0:
    LIST[1] = True 

if LIST[0] and LIST[1]:
    print("AMBIGUOUS")
elif LIST[0] and not LIST[1]:
    print("YYMM")
elif not LIST[0] and LIST[1]:
    print("MMYY")
else:
    print("NA")

Solution (Python):
s=input()
if 10*int(s[0])+int(s[1])<=12 and int(s[0])+int(s[1])!=0:
  if 10*int(s[2])+int(s[3])<=12 and int(s[2])+int(s[3])!=0:
    print("AMBIGUOUS")
  else:
    print("MMYY")
if 10*int(s[0])+int(s[1])>=13 or int(s[0])+int(s[1])==0:
  if 10*int(s[2])+int(s[3])<=12 and int(s[2])+int(s[3])!=0:
    print("YYMM")
  else:
    print("NA")

Solution (Python):
from sys import stdin
S = stdin.readline().rstrip()
zen, kou = int(S[:2]), int(S[2:])
if 13 <= zen <= 99 and 1 <= kou <= 12:
    print('YYMM')
elif zen == 0 and 1 <= kou <= 12:
    print('YYMM')
elif 1 <= zen <= 12 and 13 <= kou <= 99:
    print('MMYY')
elif 1 <= zen <= 12 and kou == 0:
    print('MMYY')
elif 1 <= zen <= 12 and 1 <= kou <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

Solution (Python):
S = input()

bef = int(S[:2])
aft = int(S[2:])

ansb = ''
ansa = ''

if bef == 0:
    if aft > 31:
        ans = 'NA'
    elif 12 < aft <= 31:
        ans = 'NA'
    elif 0 < aft <= 12:
        ans = 'YYMM'
    elif aft == 0:
        ans = 'NA'
elif bef > 31:
    if aft > 31:
        ans = 'NA'
    elif 12 < aft <= 31:
        ans = 'YYMM'
    elif 0 < aft <= 12:
        ans = 'YYMM'
    elif aft == 0:
        ans = 'NA'
elif 12 < bef <= 31:
    if aft > 31:
        ans = 'MMYY'
    elif 12 < aft <= 31:
        ans = 'AMBIGUOUS'
    elif 0 < aft <= 12:
        ans = 'YYMM'
    elif aft == 0:
        ans = 'NA'
elif bef <= 12:
    if aft > 31:
        ans = 'MMYY'
    elif 12 < aft <= 31:
        ans = 'AMBIGUOUS'
    elif 0 < aft <= 12:
        ans = 'AMBIGUOUS'
    elif aft == 0:
        ans = 'MMYY'
print(ans)

Solution (Python):
S = input()

flagYYMM = False
flagMMYY = False

T = S[2:]
T = int(T)
if 1 <= T <= 12:
    flagYYMM = True

T = S[:2]
T = int(T)
if 1 <= T <= 12:
    flagMMYY = True

if flagYYMM * flagMMYY == 1:
    ans = 'AMBIGUOUS'
elif flagYYMM == True:
    ans = 'YYMM'
elif flagMMYY == True:
    ans = 'MMYY'
else:
    ans = 'NA'

print(ans)

Solution (Python):

S=list(str(input()))
mae=S[0]+S[1]
ato=S[2]+S[3]
intmae=int(mae)
intato=int(ato)
if intmae >= 13 and intato >= 13:
    print("NA")
elif intmae <= 12 and intato <= 12:
    if intmae > 0 and intato > 0:
        print("AMBIGUOUS")
    elif intmae == 0 and intato == 0:
        print("NA")
    elif intmae == 0:
        print("YYMM")
    elif intato == 0:
        print("MMYY")
else:
    if intmae <= 12:
        if intmae != 0:
            print("MMYY")
        else:
            print("NA")
    else:
        if intato != 0:
            print("YYMM")
        else:
            print("NA")

Solution (Python):
s =list(input())
 
a=[0]*2
b=[0]*2
 
for i in range(2):
  s[i]=str(s[i])
  s[i+2]=str(s[i+2])
  a[i]=s[i]
  b[i]=s[i+2]
 
c = int(''.join(a))
d = int(''.join(b))
cnc=0
cnd=0
 
if c>0:
  if c<13:
    cnc=2
  else:
    cnc=1
 
if d>0:
  if d<13:
    cnd=2
  else:
    cnd=1
 
if cnc==0:
  if cnd==2:
    print("YYMM")
  else:
    print("NA")
    exit()
if cnc==1:
  if cnd==1:
    print("NA")
  elif cnd==2:
    print("YYMM")
  else:
    print("NA")
elif cnc==2:
  if cnd==1:
    print("MMYY")
  elif cnd==2:
    print("AMBIGUOUS")
  else:
    print("MMYY")

Solution (Python):
s = input()
ue = int(s[:2])
sita = int(s[2:4])
if ue < 1 or ue > 12:
    if 1 <= sita <= 12:
        print('YYMM')
    if sita < 1 or sita > 12:
        print('NA')
elif sita < 1 or sita > 12:
    print('MMYY')
else:
    print('AMBIGUOUS')

Solution (Python):
S = input()

s1 = int(S[:2])
s2 = int(S[2:])


def is_yymm(i1, i2):
    return (0 <= i1 < 100) and (0 < i2 < 13)


if is_yymm(s1, s2):
    if is_yymm(s2, s1):
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if is_yymm(s2, s1):
        print("MMYY")
    else:
        print("NA")

Solution (Python):
S = input()
X = int(S[0:2])
Y = int(S[2:4])

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

Solution (Python):
"""def problem1():
    N,K = map(int,input().split())
    S = list(input())
    S[K-1] = S[K-1].swapcase()
    print("".join(S))

def problem3():
    N,K = map(int,input().split())
    prob = 0
    for i in range(1,N+1):
        point = i
        count = 0
        while(point < K):
            point *= 2
            count += 1
        prob += 1/N * (1/2)**count
    print(prob)
"""
S = input()
a = int(S[0:2])
b = int(S[2:4])
LIST = [False,False]

if 1 <= b <= 12 and a >= 0:
    LIST[0] = True 
if 1 <= a <= 12 and b >= 0:
    LIST[1] = True 

if LIST[0] and LIST[1]:
    print("AMBIGUOUS")
elif LIST[0] and not LIST[1]:
    print("YYMM")
elif not LIST[0] and LIST[1]:
    print("MMYY")
else:
    print("NA")

Solution (Python):
S = input()
S1 = int(S[:2])
S2 = int(S[2:])
s_dic = {'1':'YYMM', '2':'MMYY', '3':'AMBIGUOUS', '4':'NA'}
if (S1 == 0 and S2 > 12) or (S1 > 12 and S2 == 0) or (S1 > 12 and S2 > 12) or (S1 == 0 and S2 == 0):
    print(s_dic['4'])
elif (S1 > 12 or S1 == 0) and S2 <= 12:
    print(s_dic['1'])
elif (S2 > 12 or S2 == 0) and S1 <= 12:
    print(s_dic['2'])
elif S1 <= 12 and S2 <= 12:
    print(s_dic['3'])

Solution (Python):
s=input()
s1=s[0:2]
s2=s[2:4]
a=["01","02","03","04","05","06","07","08","09","10","11","12"]

if (s1 in a) and (s2 in a):
    print("AMBIGUOUS")
elif s1 in a:
    print("MMYY")
elif s2 in a:
    print("YYMM")
else:
    print("NA")

Solution (Python):

s = input()
s_list=list(s)
s_len=len(s_list)
s_first=int(s_list[0]+s_list[1])
s_second=int(s_list[2]+s_list[3])
if s_first<13 and s_first>0: 
    if s_second<13 and s_second>0:
        print('AMBIGUOUS')
    else:
        print('MMYY')

else: 
    if s_second<13 and s_second>0:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
s = input();
first = s[0:2]
second = s[2:4]

first = int(first)
second = int(second)

if 0 < first and first < 13:
    if 0 < second and second < 13:
        print("AMBIGUOUS")
    elif (13 <= second):
        print("MMYY")
    else:
        print("MMYY")

elif 13 <= first:
    if 0 < second and second < 13:
        print("YYMM")
    elif (13 <= second):
        print("NA")
    else:
        print("NA")

else:
    if 0 < second and second < 13:
        print("YYMM")
    elif 13 <= second:
        print("NA")
    else:
        print("NA")

Solution (Python):
s = input()

pre = int(s[:2])
post = int(s[2:])

na = False

if 0<pre and pre < 13:
    pre_able_month = True
elif pre == 0:
    na = True
    pre_able_month = False
else:
    pre_able_month = False

if 0<post and post<13:
    post_able_month = True
elif post == 0:
    na = True
    post_able_month = False
else:
    post_able_month = False

if na:
    if pre_able_month:
        print("MMYY")
    elif post_able_month:
        print("YYMM")
    else:
        print("NA")
else:
    if pre_able_month and post_able_month:
        print("AMBIGUOUS")
    elif pre_able_month and not(post_able_month):
        print("MMYY")
    elif not(pre_able_month) and post_able_month:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
hoge = str(input())
a = int(hoge[:2])
b = int(hoge[2:4])
result = None

if 0 < a and a <= 12:
  result = "MMYY"
  if 0 < b and b <= 12:
    result = "AMBIGUOUS"
if 0 < b and b <= 12:
  result = "YYMM"
  if 0 < a and a <= 12:
    result = "AMBIGUOUS"
if result == None:
  result = "NA"

print(result)

Solution (Python):

def main():
    s = input()
    start = int(s[0:2])
    end = int(s[2:4])
    if start == 0 and (end > 0 and end <= 12):
        print("YYMM")
    elif (start > 0 and start <= 12) and end == 0:
        print("MMYY")
    elif 0 < start <= 12 and 0 < end <= 12:
        print("AMBIGUOUS")
    elif start > 12 and 0 < end <= 12:
        print("YYMM")
    elif 0 < start <= 12 and end > 12:
        print("MMYY")
    else:
        print("NA")
main()

Solution (Python):
S = input()

numlist = []
N = len(S)
for i in range(N):
    numlist.append(int(S[i]))

upper = numlist[0] * 10 + numlist[1]
lower = numlist[2] * 10 + numlist[3]

isMU = False
isML = False
if 0 < upper and upper <= 12:
    isMU = True
if 0 < lower and lower <= 12:
    isML = True

if isMU and not(isML):
    print("MMYY")
elif not(isMU) and isML:
    print("YYMM")
elif isMU and isML:
    print("AMBIGUOUS")
else:
    print("NA")

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

Solution (Python):
import sys
input = sys.stdin.readline
s = input()
s1 = s[:2]
s2 = s[2:]
if 1 <= int(s1) <= 12 and 1 <= int(s2) <= 12:
    print("AMBIGUOUS")
elif (not 1 <= int(s1) <= 12) and 1 <= int(s2) <= 12:
    print("YYMM")
elif 1 <= int(s1) <= 12 and (not 1 <= int(s2) <= 12):
    print("MMYY")
else:
    print('NA')

Solution (Python):
year = int(input())
i = year
lst = []
j=0
while j < 4:
    if(i%10==0):
        lst.append(0)
    else:
        lst.append(i%10)
    i //= 10 
    j+=1

a=lst[3]*10
b=lst[1]*10
c=a+lst[2]
d=b+lst[0]
if(c==0 and d==0):
    print("NA")
elif(c>0 and c<13 and d==0):
    print("MMYY")
elif(c==0 and d>0 and d<13):
    print("YYMM")
elif(c>0 and c<13 and d>0 and d<13):
    print("AMBIGUOUS")
elif(c>0 and c<13 and d>12):
    print("MMYY")
elif(c>12 and d>0 and d<13):
    print("YYMM")
elif(c>12 and d>12):
    print("NA")
elif(c>12 and d==0):
    print("NA")
elif(c==0 and d>12):
    print("NA")
else:
    print("NA")

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

Solution (Python):
S = input()
K = int(S[0]+S[1])
L = int(S[2]+S[3])
if 1<=K<=12 and 1<=L<=12:
    print("AMBIGUOUS")
if 1<=K<=12 and L == 0:
    print("MMYY")
if 1<=K<=12 and 13<=L<=99:
    print("MMYY")
if K ==0 and L == 0:
    print("NA")
if K == 0 and 1<=L<=12:
    print("YYMM")
if K == 0 and 13<=L<=99:
    print("NA")
if 13<=K<=99 and L == 0:
    print("NA")
if 13<=K<=99 and 1<=L<=12:
    print("YYMM")
if 13<=K<=99 and 13<=L<=99:
    print("NA")

Solution (Python):


S = input()

a = int(S[:2])
b = int(S[2:])
fa = 0
fb = 0

if 1<=a and a<=12:
    fa = 1

if 1<=b and b<=12:
    fb = 1

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

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

Solution (Python):
S = str(input())
F = int(S[0:2])
T = int(S[2:4])

def Greaterthan12(x):
    if x > 12:
        return 0
    else:
        if x == 0:
            return 0
        else:
            return 1
        
Fjudge = Greaterthan12(F)
Tjudge = Greaterthan12(T)
if Fjudge == 0:
    if Tjudge == 0:
        print("NA")
    else:
        print("YYMM")
else:
    if Tjudge == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")

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

Solution (Python):
def solve():
  S = input()
  front = int(S[0:2])
  back = int(S[2:4])
  if front == 0 and back == 0: return 'NA'
  f, b = False, False
  if front in range(1, 13): f = True
  if back in range(1, 13): b = True
  if front == 0 and b: return 'YYMM'
  if f and back == 0: return 'MMYY'
  if f and b: return 'AMBIGUOUS'
  if f and not b: return 'MMYY'
  if not f and b: return 'YYMM'
  if not f and not b: return 'NA'
  return 'NA'

print(solve())

Solution (Python):
S = input()

E1 = int(S[:2])
E2 = int(S[2:])

if E1 >= 1 and E1 <= 12 and E2 >= 1 and E2 <= 12:
  print('AMBIGUOUS')
elif E1 >= 1 and E1 <= 12:
  print('MMYY')
elif E2 >= 1 and E2 <= 12:
  print('YYMM')
else:
  print('NA')

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

S = list(input().strip())

y = int("{}{}".format(S[0], S[1]))
m = int("{}{}".format(S[2], S[3]))

c = 0

if m >= 1 and m <= 12:
    c += 1
if y >= 1 and y <= 12:
    c += 2

if c == 1:
    print("YYMM")
elif c == 2:
    print("MMYY")
elif c == 3:
    print("AMBIGUOUS")
elif c == 0:
    print("NA")

Solution (Python):
s=input()
strdata=list(s)
data=list(map(int,strdata))
FF=10*data[0]+data[1]
LL=10*data[2]+data[3]
if FF==0 and 0<LL and LL<13:
    print("YYMM")
elif LL==0 and 0<FF and FF<13:
    print("MMYY")
elif 12<FF and LL<13 and 0<LL:
    print("YYMM")
elif 12<LL and FF<13 and 0<FF:
    print("MMYY")
elif FF<13 and LL<13 and 0<FF and 0<LL:
    print("AMBIGUOUS")
else:
    print("NA")

Solution (Python):
s = input()
ue = int(s[:2])
sita = int(s[2:4])
if ue < 1 or ue > 12:
    if 1 <= sita <= 12:
        print('YYMM')
    if sita < 1 or sita > 12:
        print('NA')
elif sita < 1 or sita > 12:
    print('MMYY')
else:
    print('AMBIGUOUS')

Solution (Python):
def ans (n):
	a = int(n[:2])
	b = int(n[2:])
	flagA = True
	flagB = True
	if a >12 or a==0 : flagA = False
	if b>12 or b == 0 : flagB = False
	if flagA and flagB : return 'AMBIGUOUS'
	if flagA : return 'MMYY'
	if flagB : return 'YYMM'
	return 'NA'

s = input()
print(ans(s))

Solution (Python):
s=input()

tuki=['01','02','03','04','05','06','07','08','09','10','11','12']

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

flag=[1,2,3]

if a not in tuki:
    flag.remove(1)
    flag.remove(3)
if b not in tuki:
    flag.remove(2)
    if 3 in flag:
        flag.remove(3)

if flag==[]:
    print('NA')
elif flag[-1]==3:
    print('AMBIGUOUS')
elif flag[-1]==2:
    print('YYMM')
elif flag[-1]==1:
    print('MMYY')