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

def month(a, b):
    c = 10*a+b
    if 0 < c <= 12:
        return "yes"
    else:
        return "no"
    
L = [int(S[i]) for i in range(4)]
if month(L[0], L[1]) == "yes":
    if month(L[2], L[3]) == "yes":
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if month(L[2], L[3]) == "yes":
        print("YYMM")
    else:
        print("NA")

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

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

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

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

if a==0 and b==0 :
    print("NA")
elif a > 13 and b > 13 :
    print("NA")
elif a * b ==0 and ( a > 13 or b > 13) :
    print("NA")
elif a <13 and b < 13 and a*b !=0:
    print("AMBIGUOUS")
elif 0 < a <13:
    print("MMYY")
elif 0 < b <13:
    print("YYMM")

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



ab = N[0] + N[1]
cd = N[2] + N[3]




if N[0] == 0:
  ab = ab.zfill(2)

if N[2] == 0:
  cd = cd.zfill(2)





if ab == "00" and cd == "00":
  print("NA")  

elif ab == "00" and int(cd) > 12:
  print("NA")  

elif int(ab) > 12 and cd == "00":
  print("NA")  

elif int(ab) > 12 and int(cd) > 12:
  print("NA")  

elif 13 > int(ab) > 0 and 13 > int(cd) > 0:
  print("AMBIGUOUS")

elif ab == "00" and 0 < int(cd) < 13:
  print("YYMM")

elif int(ab) > 12 and int(cd) < 13:
  print("YYMM")

elif 13 > int(ab) > 0 and int(cd) > 12:
  print("MMYY")

elif 0 < int(ab) < 13 and cd =="00":
  print("MMYY")

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

if (1 <= S//100 <= 12) and (1 <= S % 100 <= 12):
    print("AMBIGUOUS")
elif 1 <= S % 100 <= 12:
    print("YYMM")
elif 1 <= S // 100 <= 12:
    print("MMYY")
else:
    print("NA")

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

Solution (Python):
s=input()
s1 = int(s[:2])
s2 = int(s[2:])
m=[]
if 1 <= s1 and s1 <= 12:
    m.append(1)
if 1 <= s2 and s2 <= 12:
    m.append(2)
if len(m) == 2:
    print("AMBIGUOUS")
elif len(m) == 1:
    if m[0] == 1:
        print("MMYY")
    else:
        print("YYMM")
else:
    print("NA")

Solution (Python):
S = input()

head, tail = S[:2], S[2:]
if 1 <= int(head) <= 12:
    print("AMBIGUOUS" if 1 <= int(tail) <= 12 else "MMYY")
else:
    print("YYMM" if 1 <= int(tail) <= 12 else "NA")

Solution (Python):
ym = 0
my = 0

s = input()

hi = int(s[2:])
lo = int(s[:2])


def isym(l):
    if l == 0:
        return False
    if l <= 12:
        return True
    else:
        return False


ym = 0
my = 0
if isym(hi):
    ym = 1
if isym(lo):
    my = 1

if ym == 1 and my == 1:
    print('AMBIGUOUS')
if ym == 1 and my == 0:
    print('YYMM')
if ym == 0 and my == 1:
    print('MMYY')
if ym == 0 and my == 0:
    print('NA')

Solution (Python):
a,b,c,d=input()
if a=='0'and b!='0'or a=='1'and b in['0','1','2']:
    if c=='0'and d!='0'or c=='1'and d in['0','1','2']:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif c=='0'and d!='0'or c=='1'and d in['0','1','2']:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()

forward = int(S[:2])
backward = int(S[2:])

if (1<=forward<=12) and (1<=backward<=12):
    print('AMBIGUOUS')
elif ((forward == 0) or (12 <= forward <= 99)) and (1<=backward<=12):
    print('YYMM')
elif ((backward == 0) or (12<=backward<=99)) and (1<=forward<=12):
    print('MMYY')
else:
    print('NA')

Solution (Python):
s = input()

f = s[:2]
l = s[2:]

if 0 < int(f) <= 12 and 0 < int(l) <= 12:
  print("AMBIGUOUS")
elif 0 < int(f) <= 12:
  print("MMYY")
elif 0 < int(l) <= 12:
  print("YYMM")
else:
  print("NA")

Solution (Python):
S = int(input())
kami = S//100
simo = S%100

if kami > 0 and kami < 13:
    kami = 1
else:
    kami = 0

if simo > 0 and simo < 13:
    simo = 1
else:
    simo = 0

if kami == 1 and simo == 0:
    print('MMYY')
elif kami == 0 and simo == 1:
    print('YYMM')
elif kami == 1 and simo == 1:
    print('AMBIGUOUS')
else:
    print('NA')

Solution (Python):

s = input()
first = int(s[0:2])
last = int(s[2:4])
if 0 < first <= 12:
    if 0 < last <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < last <= 12:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
s = input()

my,ym = 0<int(s[:2])<13,0<int(s[2:])<13

if my and ym:
    print('AMBIGUOUS')
    
elif my:
    print('MMYY')
    
elif ym:
    print("YYMM")
    
else:
    print("NA")

Solution (Python):
def isMM(date):

    n_date= int(date)

    if 1 <= n_date <= 12:
        return True
    else:
        return False

def isYY(date):

    n_date = int(date)

    if 0 <= n_date <= 99:
        return True
    else:
        return False

def isYYMM(date):

    if isYY(date[0:2]) and isMM(date[2:4]):
        return True
    else:
        return False

def isMMYY(date):

    if isMM(date[0:2]) and isYY(date[2:4]):
        return True
    else:
        return False

def main(): 

    S = input()

    if isYYMM(S) and isMMYY(S):
        print('AMBIGUOUS')
    elif isYYMM(S):
        print('YYMM')
    elif isMMYY(S):
        print('MMYY')
    else:
        print('NA')

if __name__ == "__main__":
    main()

Solution (Python):
n=input();l,r=int(n[:2])<1or int(n[:2])>12,int(n[2:])<1or int(n[2:])>12
if l and r:p="NA"
elif not(l or r):p="AMBIGUOUS"
elif l and not r:p="YYMM"
else:p="MMYY"
print(p)

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

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

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

Solution (Python):
s=list(map(str, input()))
first=int("".join(s[:2]))
last=int("".join(s[2:]))

if 1 <= first <= 12:
    if 1 <= last <= 12:
        print("AMBIGUOUS")
    elif last > 12 or last == 0:
        print("MMYY")
elif 1 <= last <= 12:
    if 1 <= first <= 12:
        print("AMBIGUOUS")
    elif first > 12 or first == 0:
        print("YYMM")
else :
    print("NA")

Solution (Python):
S = input()

my, ym = 0< int(S[:2]) <13, 0< int(S[2:]) <13

if my and ym:
	o = 'AMBIGUOUS'
elif my:
    o = 'MMYY'
elif ym:
	o = 'YYMM'
else:
	o = 'NA'
print(o)

Solution (Python):
s = list(map(int,list(input())))
ff = 10*s[0]+s[1]
ss = 10*s[2]+s[3]

if 0<=ff<=99 and 0<=ss<=99:
    if 1<=ff<=12:
        if 1<=ss<=12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if 1<=ss<=12:
            print("YYMM")
        else:
            print("NA")
else:print("NA")

Solution (Python):
s = input()
my, ym = 0<int(s[:2])<13, 0<int(s[2:])<13
if my and ym:
    o = "AMBIGUOUS"
elif my:
    o = "MMYY"
elif ym:
    o = "YYMM"
else:
    o = "NA"
print(o)

Solution (Python):
S = input()

front = int(S[0:2])
back = int(S[2:4])
if 0 < front <= 12 and 0 < back <= 12:
    print('AMBIGUOUS')
elif (front == 0 or front > 12) and 0 < back <= 12:
    print('YYMM')
elif 0 < front <= 12 and (back == 0 or back > 12):
    print('MMYY')
else:
    print('NA')

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

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

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

Solution (Python):
s = input()
x = 0

sf = s[:2]
sl = s[2:]

if (int(sf[0]) == 0 and int(sf[1]) != 0):
    x += 1
if int(sf[0]) == 1 and int(sf[1]) == 0:
    x += 1
if int(sf[0]) == 1 and int(sf[1]) == 1:
    x += 1
if int(sf[0]) == 1 and int(sf[1]) == 2:
    x += 1


if (int(sl[0]) == 0 and int(sl[1]) != 0):
    x += 2

if int(sl[0]) == 1 and int(sl[1]) == 0:
    x += 2
if int(sl[0]) == 1 and int(sl[1]) == 1:
    x += 2
if int(sl[0]) == 1 and int(sl[1]) == 2:
    x += 2

b = x

if b == 0:
  print('NA')
elif b == 3:
  print('AMBIGUOUS')
elif b == 1:
  print('MMYY')
elif b == 2:
  print('YYMM')

Solution (Python):
S=input()
F=int(S[:2]) > 0 and int(S[:2]) <13
B=int(S[2:]) > 0 and int(S[2:]) <13

print(['NA','YYMM','MMYY','AMBIGUOUS'][2*F+B])

Solution (Python):
date = input()
aa = date[0:2]
bb = date[2:4]

aa = int(aa)
bb = int(bb)

if (aa > 12 and bb > 12):
    print ('NA')
if aa>12 and bb ==0:
    print ("NA")
if aa>12 and 1<=bb<=12:
    print ("YYMM")

if (0<aa<=12 and bb ==0) or (0<aa<=12 and bb>12):
    print ("MMYY")
if 0<aa<=12 and 0<bb<=12:
    print ("AMBIGUOUS")

if (aa == 0 and bb ==0) or(aa ==0 and bb> 12):
    print ("NA")
if aa ==0 and 0< bb<=12:
    print ("YYMM")

Solution (Python):
s = input()

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

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

Solution (Python):
s = input()
a = 0
if s[:2] != '00' and s[:2] < '13':
  a += 1
if s[2:] != '00' and s[2:] < '13':
  a += 2
if a == 0:
  print('NA')
elif a == 1:
  print('MMYY')
elif a == 2:
  print('YYMM')
else:
  print('AMBIGUOUS')

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

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

Solution (Python):
from itertools import accumulate
import sys
from heapq import heappush, heappop


def main():
    input = sys.stdin.readline
    S = input()
    a = int(S[:2])
    b = int(S[2:])
    if (a > 12 or a == 0) and 1 <= b <= 12:
        print('YYMM')
    elif 1 <= a <= 12 and (b > 12 or b == 0):
        print('MMYY')
    elif 1 <= a <= 12 and 1 <= b <= 12:
        print('AMBIGUOUS')
    else:
        print('NA')


if __name__ == '__main__':
    main()

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

def which(n):
    if 1 <= n <=12:
        return 'MM'
    else:
        return 'YY'

if which(a)== 'MM' and which(b)== 'MM':
    print('AMBIGUOUS')
elif which(a)=='YY' and which(b)=='YY':
    print('NA')
else:
    print(which(a) + which(b))

Solution (Python):

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

isYM , isMY= False, False
if s1 >= 0 and s1 <= 99 and s2 >= 1 and s2 <= 12: isYM = True
if s1 >= 1 and s1 <= 12 and s2 >= 0 and s2 <= 99: isMY = True

if isYM and isMY:
    print("AMBIGUOUS")
elif isYM:
    print("YYMM")
elif isMY:
    print("MMYY")
else:
    print("NA")

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

aa = 10*int(s[0]) + int(s[1])
bb = 10*int(s[2]) + int(s[3])
if 1 <= aa <= 12 and 1 <= bb <= 12:
    print("AMBIGUOUS") 
elif 0 <= aa <= 99 and 1 <= bb <= 12:
    print("YYMM")
elif 1 <= aa <= 12 and 0 <= bb <= 99:
    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()

S_list = [c for c in S]
zenhan = 10 * int(S_list[0]) + int(S_list[1])
kouhan =  10 * int(S_list[2]) + int(S_list[3])

if zenhan > 0 and zenhan < 13:
  if kouhan > 0 and kouhan < 13:
    print('AMBIGUOUS')
    exit()
  else:
    print('MMYY')
    exit()
else:
  if kouhan > 0 and kouhan < 13:
    print('YYMM')
    exit()
  else:
    print('NA')
    exit()

Solution (Python):
S = input()

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

if a < 0 or 99 < a:
    x = 0
elif 0 <= a < 1 or 12 < a <= 99:
    x = 1
else:
    x = 2

if b < 0 or 99 < b:
    y = 0
elif 0 <= b < 1 or 12 < b <= 99:
    y = 1
else:
    y = 2

if (x == 0 or y == 0) or (x == 1 and y == 1):
    print('NA')
elif x == 1 and y == 2:
    print('YYMM')
elif x == 2 and y == 1:
    print('MMYY')
else:
    print('AMBIGUOUS')

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

Solution (Python):

S = input()
ab,cd = S[0:2],S[2:4]
if ab == "00" and cd == "00":
    print("NA")
elif int(ab) >= 13 and int(cd) >= 13:
    print("NA")
elif ab == "00" and int(cd) >=13:
    print("NA")
elif int(ab) >=13 and cd =="00":
    print("NA")
elif ab == "00" and int(cd) <= 12:
    print("YYMM")
elif int(ab) <= 12 and cd == "00":
    print("MMYY")
elif int(ab) <= 12 and int(cd) <= 12:
    print("AMBIGUOUS")
elif int(ab) <= 12 and int(cd) >= 13:
    print("MMYY")
elif int(ab) >= 13 and int(cd) <= 12:
    print("YYMM")

Solution (Python):
import sys
input = sys.stdin.readline
s = int(input())
s1 = s//100
s2 = s%100
if s1>12 or s1==0:
  if s2==0 or s2>12:
    print("NA")
  else:
    print("YYMM")
else:
  if s2==0 or s2>12:
    print("MMYY")
  else:
    print("AMBIGUOUS")

Solution (Python):
s = input()
yy = int(s[0:2])
mm = int(s[2:4])
def month(num):
  return True if 1 <= num and num <= 12 else False
  
if month(mm) and month(yy):
  print("AMBIGUOUS")
elif month(mm):
    print("YYMM")
elif month(yy):
    print("MMYY")
else:
  print("NA")

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

if 1 <= pre <= 12 and 1 <= post <= 12:
    print('AMBIGUOUS ')
elif 0 <= pre <= 99 and 1 <= post <= 12:
    print('YYMM')
elif 1 <= pre <= 12 and 0 <= post <= 99:
    print('MMYY')
else:
    print('NA')

Solution (Python):
s = input()

s1 = s[0:2]
s2 = s[2:4]
l = []

flg = 0
if 1 <= int(s1) <= 12:
    flg += 10

if 1<= int(s2) <= 12:
    flg += 1
    

if flg == 0:
    print('NA')
elif flg == 1:
    print('YYMM')
elif flg == 10:
    print('MMYY')
else:
    print('AMBIGUOUS')

Solution (Python):
S = input()

n1 = int(S[0]) * 10 + int(S[1])
n2 = int(S[2]) * 10 + int(S[3])

if 0 < n1 < 13 and 0 < n2 < 13:
    print('AMBIGUOUS')
elif 0 < n1 < 13:
    print('MMYY')
elif 0 < n2 < 13:
    print('YYMM')
else:
    print('NA')

Solution (Python):
while True:
    try:
        string = input()
        if int(string[:2]) > 0 and int(string[:2]) <= 12:
            if int(string[2:]) > 0 and int(string[2:]) <= 12:
                print('AMBIGUOUS')
            else:
                print('MMYY')
        else:
            if int(string[2:]) > 0 and int(string[2:]) <= 12:
                print('YYMM')
            else:
                print('NA')
    except:
        break

Solution (Python):

import sys


def solve(S: int):
    s = '{:04d}'.format(S)
    a, b = str(s)[:2], str(s)[2:]

    def judge(s):
        if s == '00' or int(s) > 12:
            return 'y'
        return 'ym'

    fa, fb = judge(a), judge(b)

    if fa == 'y' and fb == 'y':
        print('NA')
    elif fa == 'y' and fb == 'ym':
        print('YYMM')
    elif fa == 'ym' and fb == 'y':
        print('MMYY')
    elif fa == 'ym' and fb == 'ym':
        print('AMBIGUOUS')
    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 = input()
head = int(S[:2])
tail = int(S[2:])
if 0<head <=12 and 0<tail<=12:
  print("AMBIGUOUS")
elif 0<head<=12 and (tail>12 or tail==0):
  print("MMYY")
elif (head>12 or head ==0) and 0<tail<=12:
  print("YYMM")
else:
  print("NA")

Solution (Python):
s = input()
ymflag = True
myflag = True
head = int(s[:2])
tail = int(s[2:])
if head > 12:
    myflag = False
elif head == 0:
    myflag = False

if tail > 12:
    ymflag = False
elif tail == 0:
    ymflag = False
if ymflag and myflag:
    print("AMBIGUOUS")
elif ymflag:
    print("YYMM")
elif myflag:
    print("MMYY")
else:
    print("NA")

Solution (Python):
s=input()
a=int(s[:2])
b=int(s[2:])
def f(a):
    a1,a2=0,0
    if 1<=a<=12:
        a1=1
    if 0<=a<=99:
        a2=1
    return (a1,a2)
a1,a2=f(a)
b1,b2=f(b)
if a1 and a2 and b1 and b2:
    print('AMBIGUOUS')
elif a1 and b2:
    print('MMYY')
elif a2 and b1:
    print('YYMM')
else:
    print('NA')

Solution (Python):
X = input()

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

Solution (Python):
if __name__ == '__main__':
    S = str(input())
    
    AA = int(S[:2])
    BB = int(S[2:4])
    
    month = [i for i in range(1, 13)]
    
    if AA in month:
        if BB in month:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    
    elif BB in month:
            print('YYMM')
    
    else:
        print('NA')

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

Solution (Python):
while True:
    try:
        S = input()
        n1 = int(S[:2])
        n2 = int(S[2:])
        isYYMM = False
        isMMYY = False
        if 1<=n1<=12:
            isMMYY = True
        if 1<=n2<=12:
            isYYMM = True
        if isMMYY and isYYMM:
            print("AMBIGUOUS")
        elif (not isMMYY) and (not isYYMM):
            print("NA")
        elif isMMYY:
            print("MMYY")
        elif isYYMM:
            print("YYMM")
    except:
        break

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

if 0<int(S[:2])<=12:
  if 0<int(S[2:])<=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0<int(S[2:])<=12:
    print('YYMM')
  else:
    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() 
is_yymm = 1 <= int(S[2:]) <= 12
is_mmyy = 1 <= int(S[:2]) <= 12

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

Solution (Python):
S = input() 
is_yymm = 1 <= int(S[2:4]) <= 12
is_mmyy = 1 <= int(S[0:2]) <= 12

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

Solution (Python):

import sys


def solve(S: int):
    a = S//100
    b = S%100
    if a < 1 or a >12:
        if b < 1 or b > 12:
            print('NA')
        else:
            print('YYMM')
    else:
        if b < 1 or b > 12:
            print('MMYY')
        else:
            print('AMBIGUOUS')
    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):
a = list(input())
x = a[0]+a[1]
y = a[2]+a[3]


if x == "01" or x == "02"  or x == "03" or x == "04"  or x == "05"  or x == "06"  or x == "07"  or x == "08"  or x == "09"  or x == "10"  or x == "11"  or x == "12":
    if y == "01" or y == "02"  or y == "03" or y == "04"  or y == "05"  or y == "06"  or y == "07"  or y == "08"  or y == "09"  or y == "10"  or y == "11"  or y == "12":
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif y == "01" or y == "02"  or y == "03" or y == "04"  or y == "05"  or y == "06"  or y == "07"  or y == "08"  or y == "09"  or y == "10"  or y == "11"  or y == "12":
    print("YYMM")
else:
    print("NA")

Solution (Python):
N= input()
mae = int(N[0]+N[1])
ato = int(N[2]+N[3])
a = 0
b = 0
if 0<mae and mae<13:
  a = 1
if 0 < ato and ato < 13:
  b = 1
if a == 1:
  if b == 1:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if b == 1:
    print('YYMM')
  else:
    print('NA')

Solution (Python):
from datetime import datetime
s = input()
def is_yymm(ss):
  try:
    datetime.strptime(ss, '%y%m')
    return True
  except:
    pass
def is_mmyy(ss):
  try:
    datetime.strptime(ss, '%m%y')
    return True
  except:
    pass
if is_yymm(s) and is_mmyy(s):
  print('AMBIGUOUS')
elif is_yymm(s):
  print('YYMM')
elif is_mmyy(s):
  print('MMYY')
else:
  print('NA')

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

Solution (Python):
s = input()
s1, s2 = int(s[:2]), 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 = list(i for i in input())
x,y = int(s[0] + s[1]),int(s[2] + s[3])
if x < 13 and x > 0 and y < 13 and y > 0:
  print('AMBIGUOUS')
elif (x >= 13 or x == 0) and y < 13 and y > 0:
  print('YYMM')
elif x < 13 and x > 0 and (y >= 13 or y == 0):
  print('MMYY')
else:
  print('NA')

Solution (Python):
s = list(map(int, input()))

left = s[0]*10 + s[1]
right = s[2]*10 + s[3]

isMonthL = False
isMonthR = False

if 0 < left and left < 13:
    isMonthL = True

if 0 < right and right < 13:
    isMonthR = True

if isMonthR and isMonthL:
    print("AMBIGUOUS")
elif isMonthL and not isMonthR:
    print("MMYY")
elif not isMonthL and isMonthR:
    print("YYMM")
else:
    print("NA")

Solution (Python):
S = input()
S_list = list(S)
A = int(S_list[0]) * 10 + int(S_list[1])
B = int(S_list[2]) * 10 + int(S_list[3])

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

Solution (Python):
s = input()

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

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

if can_be_month(first) and can_be_month(second):
    print("AMBIGUOUS")
elif can_be_month(first) and not can_be_month(second):
    print("MMYY")
elif not can_be_month(first) and can_be_month(second):
    print("YYMM")
else:
    print("NA")

Solution (Python):
def main():
    S = input()

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

main()

Solution (Python):
S = input()

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


if 12>=int(head)>=1 and 12>=int(tail)>=1:
    print("AMBIGUOUS")
elif 12>=int(head)>=1:
    print("MMYY")
elif 12>=int(tail)>=1:
    print("YYMM")
else:
    print("NA")

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

Solution (Python):
msg=input()
pp=msg[0:1+1];p=int(pp)
qq=msg[2:3+1];q=int(qq)
if 1<=p<=12:
  if 1<=q<=12:
  	print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=q<=12:
    print("YYMM")
  else:
    print("NA")

Solution (Python):
S = int(input())
x = 0
a = S//100
b = S%100
if a>=1 and a<=12:
    x+=1
if b>=1 and b<=12:
    x+=1
if x == 0:
    print("NA")
elif x == 2:
    print("AMBIGUOUS")
if x == 1:
    if a>=1 and a<=12:
        print("MMYY")
    else:
        print("YYMM")

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


def is_m(x):
    return 0 < x < 13


if is_m(y) and is_m(m):
    print('AMBIGUOUS')
elif not is_m(y) and not is_m(m):
    print('NA')
elif not is_m(y) and is_m(m):
    print('YYMM')
else:
    print('MMYY')

Solution (Python):
S = int(input())
a = S // 100
b = S % 100

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

Solution (Python):
S = input()
n = int(S[:2])
m = int(S[2:])
flgs = [0, 0]
if 0 < n and n < 13:
  flgs[0] = 1
if 0 < m and m < 13:
  flgs[1] = 1
if flgs[0]:
  if flgs[1]:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if flgs[1]:
    print('YYMM')
  else:
    print('NA')

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

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

Solution (Python):
S =input()

ans = "NA"
if 0 < int(S[0])*10+int(S[1]) < 13 :
    ans = "MMYY"
if 0<int(S[2])*10+int(S[3])<13:
    if ans == "MMYY":
         ans ="AMBIGUOUS"
    else: ans ="YYMM"
print(ans)

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

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

Solution (Python):
S = input()

def isMonth(S):
    if 1<=int(S)<=12:
        return True
    else:
        return False

s1, s2 = S[:2], S[2:]
if isMonth(s1) & isMonth(s2):
    print('AMBIGUOUS')
elif isMonth(s1):
    print('MMYY')
elif isMonth(s2):
    print('YYMM')
else:
    print('NA')

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

left = int(s[0]) * 10 + int(s[1])
right = int(s[2]) * 10 + int(s[3])

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

Solution (Python):
a, b, c, d = list(input())
a = int(a)
b = int(b)
c = int(c)
d = int(d)
if 0 < 10*a + b <= 12 and 0 < c*10 + d <= 12:
    print('AMBIGUOUS')
elif (10*a + b >= 12 or a + b == 0) and 0 < c*10 + d <= 12:
    print('YYMM')
elif 0 < 10*a + b <= 12 and (c*10 + d >= 12 or c + d == 0):
    print('MMYY')
else:
    print('NA')

Solution (Python):
s = input()

year = int(s[0:2])
month = int(s[2:4])

mmy = False
yym = False

if 1 <= year <= 12:
    mmy = True
if 1 <= month <=12:
    yym = True
if mmy and yym:
    print('AMBIGUOUS')
elif yym:
    print('YYMM')
elif mmy:
    print('MMYY')
else:
    print('NA')

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

if former>0 and former<13:
    if latter>0 and latter<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if latter>0 and latter<13:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
S = input()
a = int(S[0:2])
b = int(S[2:4])
fym = False
fmy = False
if 1<=a<=12:
  fmy = True
if 1<=b<=12:
  fym = True
if fmy and fym:
  print("AMBIGUOUS")
elif fmy:
  print("MMYY")
elif fym:
  print("YYMM")
else:
  print("NA")

Solution (Python):
S = input()
M = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]

f = False
f2 = False
if (S[2:] in M): f = True
if (S[:2] in M): f2 = True

if f and f2:
    print ("AMBIGUOUS")
elif f:
    print ("YYMM")
elif f2:
    print ("MMYY")
else:
    print ("NA")

Solution (Python):
s=input()
a,b=int(s[:2]),int(s[2:])
print(['NA','MMYY','YYMM','AMBIGUOUS'][(0<a<13)-(0<b<13)*2])

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

if int(S[:2])>0 and int(S[:2])<13:
  a=True
else:
  a=False
  
if int(S[2:])>0 and int(S[2:])<13:
  b=True
else:
  b=False
  
if a==True and b==True:
  print('AMBIGUOUS')
elif a==True and b==False:
  print('MMYY')
elif a==False and b==True:
  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 = input()
former = int(s[0]+s[1])
latter = int(s[2]+s[3])

A = former > 0 and former < 13
B = latter > 0 and latter < 13

if A and B:
    print('AMBIGUOUS')
elif A:
    print('MMYY')
elif B:
    print('YYMM')
else:
    print('NA')

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