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):
S=input()
XXX=int(S[0:2])
YYY=int(S[2:4])

YM=False
MY=False


if YYY<13 and YYY>0:
	MY=True


if XXX>0 and XXX<13:
	YM=True


if MY and YM :
	print("AMBIGUOUS")
elif MY:
	print("YYMM")
elif YM:
	print("MMYY")
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 = int(S[:2])
b = int(S[2:])

if a > 12:
	if b > 12:
		print("NA")
	elif b > 0:
		print("YYMM")
	else:
		print("NA")

if 0 < a <= 12:
	if b > 12 or b == 0:
		print("MMYY")
	else:
		print("AMBIGUOUS") 

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

Solution (Python):
S = input()




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

Solution (Python):
S_line = [i for i in input()]
S_line_mae = [S_line[0],S_line[1]]
S_line_ushiro = [S_line[2],S_line[3]]
moji_mae = ''.join(S_line_mae)
moji_ushiro = ''.join(S_line_ushiro)

mae = int(moji_mae)
ushiro = int(moji_ushiro)
if (mae==0 or mae>=13) and ushiro>=1 and ushiro<=12:
  print('YYMM')
elif mae>=1 and mae<=12 and (ushiro==0 or ushiro>=13):
  print('MMYY')
elif mae>=1 and mae<=12 and ushiro>=1 and ushiro<=12:
  print('AMBIGUOUS')
else:
  print('NA')

Solution (Python):
a = str(input())
a = list(a)
b = int(''.join(a[0: 2]))
c = int(''.join(a[2: 4]))
if (99 >= b > 12):
    if (c > 12):
        print('NA', end='')
    elif(12 >= c >= 1):
        print('YYMM', end='')
    else:
        print('NA', end='')
elif (12 >= b > 0):
    if (c > 12):
        print('MMYY', end='')
    elif(12 >= c > 0):
        print('AMBIGUOUS', end='')
    elif(c == 0):
        print('MMYY', end='')
    else:
        print('NA', end='')
elif (b == 0):
    if (99 >= c >= 1):
        print('YYMM', end='')
    else:
        print('NA', end='')

Solution (Python):
import sys
import math 
import numpy as np
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
S=ns()

f=int(S[0:2])
r=int(S[2:4])


if(f<=12 and f>=1 and r<=12 and r>=1):
    print("AMBIGUOUS")
elif(f<=12 and f>=1):
    print("MMYY")
elif(r<=12 and r>=1):
    print("YYMM")
else:
    print("NA")

Solution (Python):
s = str(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 0 <= s2 <= 99 and 1 <= s1 <= 12:
    print('MMYY')
else:
    print('NA')

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

Solution (Python):
a, b, m, n = list(input())
ab = int(a+b)
mn = int(m+n)
if 1<=ab<=12 and 1<=mn<=12:
    print("AMBIGUOUS")
elif 1<=ab<= 12 and not 1<=mn<=12:
    print("MMYY")
elif not 1<=ab<=12 and 1<=mn<=12:
    print("YYMM")
else:
    print("NA")

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

Solution (Python):
def check(c):
	if(48<=ord(c)<=57):
		return True
	return False

S=input()

if( (not check(S[0])) or (not check(S[1])) or (not check(S[2])) or (not check(S[3]))):
	print("NA")
else:
	v1=int(S[:2])
	v2=int(S[2:])

	y1=(v1>=0)
	m1=(12>=v2>0)
	b1=(y1 and m1)

	m2=(12>=v1>0)
	y2=(v2>=0)
	b2=(y2 and m2)

	if(b1 and b2):
		print("AMBIGUOUS")
	elif(b1):
		print("YYMM")
	elif(b2):
		print("MMYY")
	else:
		print("NA")

Solution (Python):
a = input()

a = list(a)
b = a[0]+a[1]
c = a[2]+a[3]

b = int(b)
c = int(c)

if c >= 1 and c <= 12 and b >= 1 and b <= 12:
        print("AMBIGUOUS")

elif c >= 1 and c <= 12:
    print("YYMM")

elif b >= 1 and b <= 12:
    if c >= 1 and c <= 12:
        print("AMBIGUOUS")
    print("MMYY")
    
else:
    print('NA')

Solution (Python):
a=input()

b = int(a[:2])
c = int(a[2:])

if 0< b < 13:
    a_month_flag = 1
    a_year_flag = 1
elif b == 0:
    a_month_flag = 0
    a_year_flag = 0
else:
    a_month_flag = 0
    a_year_flag = 1

if 0< c < 13:
    b_month_flag = 1
    b_year_flag = 1
elif c == 0:
    b_month_flag = 0
    b_year_flag = 0
else:
    b_month_flag = 0
    b_year_flag = 1

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

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

f1 = (1 <= int(s1) <= 12)
f2 = (1 <= int(s2) <= 12)
ans = ""
if f1 and f2:
    ans = "AMBIGUOUS"
elif f1 and (not f2):
    ans = "MMYY"
elif (not f1) and f2:
    ans = "YYMM"
else:
    ans = "NA"

print(ans)

Solution (Python):
S = input()
SL = int(S[0:2])
SR = int(S[2:4])

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

Solution (Python):
s=int(input())
num=[]
while s > 0:
    num.append(s % 100)
    s //= 100

if len(num)==0:
    num.append(0)
if len(num)==1:
    num.append(0)
num.reverse()

if num[0]<=12 and num[0]>0:
    if num[1]<=12 and num[1]>0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if num[1]<=12 and num[1]>0:
        print("YYMM")
    else:
        print("NA")

Solution (Python):

def main():
    S = input()

    A = int(S[:2])
    B = int(S[2:])

    if A != 0 and B <= 12 and B != 0 and A <= 12:
        print("AMBIGUOUS")

    elif (A != 0 and B <= 12) and B != 0:
        print("YYMM")

    elif (B != 0 and A <= 12) and A != 0:
        print("MMYY")

    elif (A == 0 and 1 <= B and B <= 12):
        print("YYMM")

    elif (B == 0 and 1 <= A and A <= 12):
        print("MMYY")

    else:
        print("NA")


if __name__ == "__main__":
    main()

Solution (Python):
import sys

input = sys.stdin.readline


def check_format(num):
    if not num:
        return 0
    if num <= 12:
        return 1
    return 2


def main():
    s = input()
    f = int(s[:2])
    b = int(s[2:])
    f_format = check_format(f)
    b_format = check_format(b)
    format_ = "AMBIGUOUS"
    if set([f_format, b_format]) == {2}:
        format_ = "NA"
    if set([f_format, b_format]) == {0}:
        format_ = "NA"
    if [f_format, b_format] == [0, 2] or [f_format, b_format] == [2, 0]:
        format_ = "NA"
    if f_format == 1 and b_format in (0, 2):
        format_ = "MMYY"
    if f_format in (0, 2) and b_format == 1:
        format_ = "YYMM"
    print(format_)


if __name__ == "__main__":
    main()

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

Solution (Python):
S = input()

A,B = int(S[:2]),int(S[2:])

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

Solution (Python):
s = list(input())
bef=int(s[0])*10+int(s[1])
aft=int(s[2])*10+int(s[3])

ans=''
if 0<aft<13 and 0<bef<13:
  ans='AMBIGUOUS'
elif (100>aft>12 or aft==0) and 0<bef<13:
  ans='MMYY'
elif (100>bef>12 or bef==0) and 0<aft<13:
  ans='YYMM'
else:
  ans='NA'
print(ans)

Solution (Python):
import re 
S=input()
def YM(S):
  if re.match("(00|1[3-9]|[2-9][0-9])(0[1-9]|1[0-2])",S):
    return "YYMM"
  elif re.match("(0[1-9]|1[0-2])(00|1[3-9]|[2-9][0-9])",S):
    return "MMYY"
  elif re.match("(0[1-9]|1[0-2])(0[1-9]|1[0-2])",S):
    return "AMBIGUOUS"
  else:
    return "NA"
print("{}".format(YM(S)))

Solution (Python):



from collections import deque
import heapq
import math
import bisect


def main():
    S = input()

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


if __name__ == '__main__':
    main()

Solution (Python):
def is_mm(target):
    n = int(target)
    return 1 <= n <= 12


def get_result(first2_is_mm, last2_is_mm):
    if first2_is_mm and last2_is_mm:
        return "AMBIGUOUS"
    if not first2_is_mm and not last2_is_mm:
        return "NA"
    if first2_is_mm:
        return "MMYY"
    return "YYMM"


s = str(input())
first2, last2 = ((i + j) for (i, j) in zip(s[::2], s[1::2]))
print(get_result(is_mm(first2), is_mm(last2)))

Solution (Python):
hoge=input()
ho=int(hoge[:2])
ge=int(hoge[2:])
ym=0
my=0
if(1<=ge and ge<=12):
  ym=1
  
if(1<=ho and ho<=12):
  my=1
  
if(ym==1 and my==1):
  print("AMBIGUOUS")
elif(ym==1):
  print("YYMM")
elif(my==1):
  print("MMYY")
else:
  print("NA")

Solution (Python):
s=input()

t=int(s[0:2])
u=int(s[2:4])

if t==0:
    if 1<=u and u<=12:
        print("YYMM")
    else:
        print("NA")

elif 1<=t and t<=12:
    if u==0 or 12<u:
        print("MMYY")
    else:
        print("AMBIGUOUS")

else:
    if u==0 or 12<u:
        print("NA")
    else:
        print("YYMM")

Solution (Python):
def main():
    S = input()
    S1 = S[0]+S[1]
    S2 = S[2]+S[3]
    
    isS1YY = True if 0 <= int(S1)  and int(S1) <= 99 else False
    isS2MM = True if 1 <= int(S2) and int(S2) <= 12 else False
    isS1MM = True if 1 <= int(S1) and int(S1) <= 12 else False
    isS2YY = True if 0 <= int(S2) and int(S2) <= 99 else False
    if isS1YY and isS2MM and isS1MM is False or isS2YY is False:
        print('YYMM')
        exit()
    if isS1MM and isS2YY:
        if isS1YY == False or isS2MM == False:
            print('MMYY')
            exit()
    if isS1YY and isS2MM and isS1MM and isS2YY:
        print('AMBIGUOUS')
        exit()
    print('NA')
main()

Solution (Python):
s = str(input())
mae = int(s[0:2])
ato = int(s[2:4])

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

Solution (Python):
S=input()
u = int(S[0:2])
l = int(S[2:4])

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

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

Solution (Python):

S =input()
if "00" < S[0:2] <="12" and "13" <= S[2:4] <= "99":
    print("MMYY")
elif "13" <= S[0:2] <= "99" and "00" <S[2:4] <= "12":
    print("YYMM")
elif "00" < S[0:2] <= "12" and "00" < S[2:4] <= "12":
    print("AMBIGUOUS")
elif "00" == S[0:2] and "00" < S[2:4] <= "12":
    print("YYMM")
elif "00" < S[0:2] <= "12" and S[2:4] == "00":
    print("MMYY")
else:
    print("NA")

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

if S1>=13 or S1==0:
  if S2>=13 or S2==0:
    print("NA")
  else:
    print("YYMM")
else:
  if S2>=13 or S2==0:
    print("MMYY")
  else:
    print("AMBIGUOUS")

Solution (Python):
def yymm_or_mmyy(s):
    yymm = 'YYMM'
    mmyy = 'MMYY'
    abmg = 'AMBIGUOUS'
    na = 'NA'

    top = s[0] + s[1]
    bot = s[2] + s[3]

    if is_mm(top):
        out = abmg if is_mm(bot) else mmyy
    else:
        out = yymm if is_mm(bot) else na

    return out

def is_mm(s):
    mm = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
    return s in mm

s = str(input())
out = yymm_or_mmyy(s)
print(out)

Solution (Python):
import sys

s = input()
s = s[:4]
a = s[:2]
b = s[2:]

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

	print("AMBIGUOUS")
	sys.exit()


elif int(a) >= 0 and 0 < int(b) <= 12:

	print("YYMM")
	sys.exit()

elif 0 < int(a) <= 12 and int(b) >= 0:

	print("MMYY")
	sys.exit()

print("NA")

Solution (Python):
S=input()
S1=int(S[:2])
S2=int(S[2:])

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

Solution (Python):
def check(S) :
    mae = int(S[:2])
    ato = int(S[2:])
    
    if mae == 0 and ato <= 12 and ato > 0 :
        return "YYMM"
    if ato == 0 and mae <= 12 and mae > 0 :
        return "MMYY"
    
    if mae == 0 or ato == 0 :
        return "NA"
    if mae > 12 and ato > 12 :
        return "NA"
    if mae <= 12 and ato <= 12 :
        return "AMBIGUOUS"
    if mae > 12 :
        return "YYMM"

    return "MMYY"
    
    

S = input()
print(check(S))

Solution (Python):
s = input()

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

if 1 <= aa <= 12:
    print('AMBIGUOUS') if 1 <= bb <= 12 else print('MMYY')
else:
    print('YYMM') if 1 <= bb <= 12 else print('NA')

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


a=int(n[0:2])
b=int(n[2:4])

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

Solution (Python):


S=list(str(input()))
S1=int("".join(S[0:2]))
S2=int("".join(S[2:4]))

if 1 <= S1 <= 12:
    s1="MM"
else:
    s1="YY"
    
if 1 <= S2 <= 12:
    s2="MM"
else:
    s2="YY"


if s1 != s2:
    print(s1+s2)
else:
    if s1 == "MM" and s2 == "MM":
        print("AMBIGUOUS")
    elif S1 == 0 and s2 =="MM":
        print("YYMM")
    elif s1 == "MM" and S1 == 0:
        print("MMYY")
    else:
        print("NA")

Solution (Python):
s=input()
sf,sl=int(s[:2]),int(s[2:])
if (sf>=1 and sf<=12):
    print("AMBIGUOUS" if (sl>=1 and sl<=12) else "MMYY")
else:
    print("YYMM" if (sl>=1 and sl<=12) else "NA")

Solution (Python):

S = list(map(int,input()))
A = S[0] * 10 + S[1]
B = S[2] * 10 + S[3]
if A <= 12 and A > 0:
  if B <= 12 and B > 0:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if B <= 12 and B > 0:
    print("YYMM")
  else:
    print("NA")

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

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

Solution (Python):
S=input()

S_1=int(S[0]+S[1])
S_2=int(S[2]+S[3])

if S_1 in range(1, 13):
    
    if S_2 in range(1,13):
        print("AMBIGUOUS")
    else :
        print("MMYY")

elif S_1 ==0:
    if S_2 in range(1,13):
        print("YYMM")
    else:
        print("NA")

elif S_1 >12:
    if S_2 in range(1,13):
        print("YYMM")
    else :
        print("NA")

Solution (Python):

status = ['NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'MMYY', 'MMYY', 'NA', 'YYMM', 'NA', 'YYMM', 'NA', 'YYMM', 'MMYY', 'AMBIGUOUS']

def isMonth(a):
    return a > 0 and a < 13

def isYear(a):
    return a > -1 and a < 100

t = input()
t1 = int(t[:2])
t2 = int(t[2:])

judge = isYear(t1) * 8 + isMonth(t1) * 4 + isYear(t2) * 2 + isMonth(t2)
print(status[judge])

Solution (Python):
def main():
    s = input()
    l = int(s[0:2])
    r = int(s[2:4])

    if check(l) == 2 and check(r) == 2:
        print("AMBIGUOUS")
        return
    elif check(l) != 2 and check(r) == 2:
        print("YYMM")
        return
    elif check(l) == 2 and check(r) != 2:
        print("MMYY")
        return
    else:
        print("NA")

def check(num):
    if num == 0:
        return 1
    elif 1 <= num and num <= 12:
        return 2
    else:
        return 3

if __name__ == "__main__":
    main()

Solution (Python):
s = input()

sf = int(s[:2])
sb = int(s[2:4])

ans = ""

if 1 <= sf <= 12:

    if 1 <= sb <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"

else:

    if 1 <= sb <= 12:
        ans = "YYMM"
    else:
        ans = "NA"

print(ans)

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op



inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    
    s = get_str()
    a, b = int(s[:2]), int(s[2:])
    if 1 <= a <= 12 and 1 <= b <= 12:
        print('AMBIGUOUS')
    elif 1 <= b <= 12 and (a == 0 or a > 12):
        print('YYMM')
    elif 1 <= a <= 12 and (b == 0 or b > 12):
        print('MMYY')
    else:
        print('NA')
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Solution (Python):
from datetime import date
s = str(input())
f = int(s[:2])
l = int(s[2:])

def validate_date(m):
  try:
    date(2000, int(m), 1)
    return True
  except ValueError:
    return False

f_month = 0
l_month = 0

if(validate_date(f)): f_month = 1
if(validate_date(l)): l_month = 1

if(l_month == 1 and f_month == 1):print('AMBIGUOUS')

if(l_month == 1 and f_month == 0):print('YYMM')

if(l_month == 0 and f_month == 1):print('MMYY')

if(l_month == 0 and f_month == 0):print('NA')

Solution (Python):
S = input()
s_list = list(S)
s_list_i = [int(s) for s in s_list ]
a = int(s_list[0] + s_list[1])
b = int(s_list[2] + s_list[3])

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

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

Solution (Python):
s =input()
ym=0
my=0
d1=int(s[0:2])
d2=int(s[2:4])


if 0<=d1:
    ym+=1
    if 0<d1<13:
        my+=1

if 0<=d2:
    my+=1
    if 0<d2<13:
        ym+=1
    
if ym==2 and my==2:
    print("AMBIGUOUS")    
elif ym==2:
    print("YYMM")
elif my==2:
    print("MMYY")
else:
    print("NA")

Solution (Python):
s = input()
my1 = int(s[0:2])
my2 = int(s[2:])
my1t = False
my2t = False
if my1 >= 13 or my1 == 0:
    my1t = True
if my2 >= 13 or my2 == 0:
    my2t = True
if my1t == True and my2t == False:
    print('YYMM')
elif my1t == False and my2t == True:
    print('MMYY')
elif my1t == False and my2t == False:
    print('AMBIGUOUS')
else:
    print('NA')

Solution (Python):
import re 
S=input()
def YM(S):
  if re.match("(00|1[3-9]|[2-9][0-9])(0[1-9]|1[0-2])",S):
    return "YYMM"
  elif re.match("(0[1-9]|1[0-2])(00|1[3-9]|[2-9][0-9])",S):
    return "MMYY"
  elif re.match("(0[1-9]|1[0-2])(0[1-9]|1[0-2])",S):
    return "AMBIGUOUS"
  else:
    return "NA"
print("{}".format(YM(S)))

Solution (Python):
s=int(input())
a=s//100
b=s%100
if a>12 and b>12 or a==0 and b>12 or b==0 and a>12 or a==0 and b==0:print("NA")
elif a>12 or a==0:print("YYMM")
elif b>12 or b==0:print("MMYY")
else:print("AMBIGUOUS")

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns()) 
na = lambda: list(map(int, stdin.readline().split())) 
ns = lambda: stdin.readline().rstrip()  

s=ns()
if (s[0:2]<="12")&(s[0:2]>"00")&((s[2:4]>"12")|(s[2:4]=="00")):
	print("MMYY")
elif (s[0:2]<="12")&(s[0:2]>"00")&(s[2:4]<="12")&(s[2:4]>"00"):
	print("AMBIGUOUS")
elif ((s[0:2]>"12")|(s[0:2]=="00"))&(s[2:4]<="12")&(s[2:4]>"00"):
	print("YYMM")
else:
	print("NA")

Solution (Python):

import sys


def solve(S: int):
    S = '{:04}'.format(S)
    a = int(S[:2])
    b = int(S[2:])
    if 0<a and a<13 and 0<b and b<13:
        print('AMBIGUOUS')
    elif 0<a and a<13:
        print('MMYY')
    elif 0<b and b<13:
        print('YYMM')
    else:
        print('NA')
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):
S = int(input())
yymm = True
mmyy = True


if S >= 1300 or S < 100:
    mmyy = False
if S%100 >= 13 or S%100 == 0:
    yymm = False

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

Solution (Python):

def YYMM(sub):
    if 1 <= sub <= 12:
        return True
    else:
        return False

def MMYY(up):
    if 1 <= up <= 12:
        return True
    else:
        return False

if __name__ == '__main__':
    S = input()
    up = int(''.join([S[0],S[1]]))
    sub = int(''.join([S[2],S[3]]))
    a = [YYMM(sub),MMYY(up)]
    if a[0] == a[1]:
        if a[0] == True and a[1] == True:
            ans = 'AMBIGUOUS'
        else:
            ans = 'NA'
    else:
        if a[0] == True:
            ans = 'YYMM'
        else:
            ans = 'MMYY'

    print(ans)

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[0:2])
S2=int(S[2:4])
if (S1==0 or S1>12) and (S2==0 or S2>12):print("NA");exit()
if (S1==0 or S1>12):print("YYMM");exit()
if (S2==0 or S2>12):print("MMYY");exit()
print("AMBIGUOUS")

Solution (Python):
s = input()

a = s[0:2]
b = s[2:4]

if a == "00":
    if b == "00" or int(b) > 12:
        print("NA")
    else:
        print("YYMM")
elif b == "00":
    if  int(a) > 12:
        print("NA")
    else:
        print("MMYY")
elif int(a) > 12:
    if int(b) >12:
        print("NA")
    else:
        print("YYMM")
elif int(b) > 12:
    if int(a) >12:
        print("NA")
    else:
        print("MMYY")
else:
    print("AMBIGUOUS")

Solution (Python):
s = input()
sl = list(map(int, [s[0:2],s[2:]]))
f,l = sl[0], sl[1]
if (f ==0 and (l ==0 or l >12)) or (l ==0 and (f==0 or f>12)) :
    print('NA')
elif (f>12 and l<13) or f==0:
    print('YYMM')
elif (f<13 and l>12) or l==0:
    print('MMYY')
elif f < 13 and l <13:
    print('AMBIGUOUS')
else:
  print('NA')

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

Solution (Python):

import numpy as np
import types


i = list(input())
r = int(i[0] + i[1])
l = int(i[2] + i[3])


out = ""
if 1 <= r & r <= 12:
    out += "MM"
else:
    out += "YY"

if 1 <= l & l <= 12:
    out += "MM"
else:
    out += "YY"


if out == "MMMM":
    print("AMBIGUOUS")
elif out == "YYYY":
    print("NA")
else:
    print(out)

Solution (Python):
S=list(input())
BE=[int(S[0]),int(S[1])]
AF=[int(S[2]),int(S[3])]
b_flag=0
a_flag=0
if BE[0] == 0 and BE[1]>=1:
    b_flag=1
if BE[0] == 1 and BE[1] <=2:
    b_flag=1
if AF[0] == 0 and AF[1]>=1:
    a_flag=1
if AF[0] == 1 and AF[1] <=2:
    a_flag=1
if a_flag ==1 and b_flag==1:
    print('AMBIGUOUS')
elif a_flag ==1:
    print('YYMM')
elif b_flag==1:
    print('MMYY')
else:
    print('NA')

Solution (Python):
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    S = single_input()
    YYMM = False
    MMYY = False
    if 1 <= int(S[2:]) <= 12: YYMM = True
    if 1 <= int(S[:2]) <= 12: MMYY = True

    if YYMM and MMYY: print("AMBIGUOUS")
    elif YYMM: print("YYMM")
    elif MMYY: print("MMYY")
    else: print("NA")
    return 0
  
if __name__ == "__main__":
    solve()

Solution (Python):
import sys

s = input()
s = s[:4]
a = s[:2]
b = s[2:]

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

	print("AMBIGUOUS")
	sys.exit()


if int(a) >= 0 and 0 < int(b) <= 12:

	print("YYMM")
	sys.exit()

if 0 < int(a) <= 12 and int(b) >= 0:

	print("MMYY")
	sys.exit()

print("NA")

Solution (Python):
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<=s2<=12)and(0<=s1<=99):
    print('YYMM')
elif (1<=s1<=12)and(0<=s2<=99):
    print('MMYY')
else:
    print('NA')

Solution (Python):
s=input()
ls=[int(c) for c in s]

if ((ls[0]*10+ls[1]>12) or (ls[0]==0 and ls[1]==0)) and ((ls[2]*10+ls[3]>12) or (ls[2]==0 and ls[3]==0)):
    print("NA")
elif ((ls[0]*10+ls[1]>12) or (ls[0]==0 and ls[1]==0)):
    print("YYMM")
elif ((ls[2]*10+ls[3]>12) or (ls[2]==0 and ls[3]==0)):
    print("MMYY")
else:
    print("AMBIGUOUS")

Solution (Python):
s = input()
first = int(s[0:2])
last = int(s[2:4])

if 1 <= first <= 12:
    first_flag = 0
elif first > 12 or first == 0:
    first_flag = 1
else:
    first_flag = 2

if 1 <= last <= 12:
    last_flag = 0
elif last > 12 or last == 0:
    last_flag = 1
else:
    last_flag = 2

if first_flag == last_flag == 0:
    print("AMBIGUOUS")
elif first_flag + last_flag == 1:
    if first_flag == 1:
        print("YYMM")
    else:
        print("MMYY")
else:
    print("NA")

Solution (Python):

def main():
    flg = 0
    answer = ['NA','AMBIGUOUS','YYMM','MMYY']
    data = list(input())
    front = data[0] + data[1]
    back = data[2] + data[3]
    front = int(front)
    back = int(back)
    if 1<=front<=12 and 1<=back<=12:
        flg = 1
    elif 0<=front<=99 and 1<=back<=12:
        flg = 2
    elif 1<=front<=12 and 0<=back<=99:
        flg = 3
    print(answer[flg])
if __name__ == '__main__':
    main()

Solution (Python):
n = input()

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

Solution (Python):
S = input()
list = [(i + j) for (i,j) in zip(S[::2],S[1::2])]
if int(list[0]) >= 1 and int(list[0]) <= 12:
     if int(list[1]) >= 1 and int(list[1]) <= 12:
         print("AMBIGUOUS")
     else:
         print("MMYY")
else:
     if int(list[1]) >= 1 and int(list[1]) <= 12:       
         print("YYMM")
     else:
         print("NA")

Solution (Python):
S = input()

front = S[:2]
back =  S[2:]



if front == '00':
  out_front = 'NA'
elif int(front) >= 13:
  out_front = 'YY'
else:
  out_front = 'AMBIGUOUS'
  
if back == '00':
  out_back = 'NA'
elif int(back) >= 13:
  out_back = 'YY'
else:
  out_back = 'AMBIGUOUS'
  


if out_front == 'NA' and out_back == 'AMBIGUOUS':
  out = 'YYMM'
elif out_front == 'NA' and out_back == 'YY':
  out = 'NA'  
elif out_front == 'AMBIGUOUS' and out_back == 'NA':
  out = 'MMYY'
elif out_front == 'YY' and out_back == 'NA':
  out = 'NA'
elif out_front == 'NA' and out_back == 'NA':
  out = 'NA'
elif out_front == 'YY' and out_back == 'YY':
  out = 'NA'
elif out_front == 'YY' and out_back == 'AMBIGUOUS':
  out =  'YYMM'
elif out_front == 'AMBIGUOUS' and out_back == 'YY':
  out =  'MMYY'
elif out_front == 'AMBIGUOUS' and out_back == 'AMBIGUOUS':
  out =  'AMBIGUOUS'
else:
  out = 'hoge'
  
print(out)

Solution (Python):
li = list(input())
front = int(li[0]+li[1])
back = int(li[2]+li[3])

if front > 0 and front < 13:
    if back > 0 and back < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
        
else:
    if back > 0 and back < 13:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
a=input()

P=a[-2:]
Q=a[0:2]

if int(P)<=12 and int(Q)<=12 and not int(P)==0 and not int(Q)==0:
    print('AMBIGUOUS')
elif (int(P)>12 or int(P)==0) and (int(Q)>=12 or int(Q)==0): 
    print('NA')
elif (int(P)<=12 and not int(P)==0 )and (int(Q)>=12 or int(Q)==0):
    print('YYMM')
elif (int(P)>=12 or int(P)==0) and (int(Q)<=12 and not int(Q)==0):
    print('MMYY')

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

Solution (Python):
s =input()
li = [(i+j) for (i,j) in zip(s[::2],s[1::2])]

if (int(li[0])>12)&(int(li[0])>0):
  if (int(li[1])>12)|(int(li[1])==0):
  	print('NA')
  else:
    print('YYMM')
elif int(li[0])==0:
  if int(li[1])==0:
    print('NA')
  else:
    print('YYMM')
else:
  if (int(li[1])>12)|(int(li[1])==0):
    print('MMYY')
  else:
    print('AMBIGUOUS')