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()
aa=s[:2]
bb=s[2:]

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def biger12(s):
    if int(s[0]) >= 2:
        return True
    if int(s[0]) == 1 and int(s[1])>=3:
        return True

    if int(s[0]) == 0 and int(s[1]) == 0:
        return True
        
    return False

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

    if biger12(s1) and biger12(s2):
        print('NA')
    elif not biger12(s1) and not biger12(s2):
        print('AMBIGUOUS')
    elif biger12(s1) and not biger12(s2):
        print('YYMM')
    else:
        print('MMYY')



solve()

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

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

Solution (Python):
def hantei(st):
    if 0<int(st)<=12:
        return True
    else:
        return False

S =input()
if hantei(S[0:2])and hantei(S[2:]):
    print("AMBIGUOUS")
elif hantei(S[0:2])and not hantei(S[2:]):
    print("MMYY")
elif not hantei(S[0:2])and hantei(S[2:]):
    print("YYMM")
else:
    print("NA")

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())

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

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


if __name__ == '__main__':
    print(main())

Solution (Python):
s=input()
A=int(s[:2])
B=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):
a,b,c,d=map(int,list(input()))
x=a*10+b
y=c*10+d

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

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

Solution (Python):
def is_ym(a, b):
    if 1 <= int(b) and int(b) <= 12:
        return True
    return False

def solve(s):
    a = s[:2]
    b = s[2:]
    if is_ym(a, b):
        if is_ym(b, a):
            print("AMBIGUOUS")
        else:
            print("YYMM")
    else:
        if is_ym(b, a):
            print("MMYY")
        else:
            print("NA")
            
s = input()
solve(s)

Solution (Python):
li = int(input())
a = li//100
b = li-a*100
p = 0
q = 0
if 0<a<13:
    p=1
if 0<b<13:
    q=1
if p==1 and q==1:
    print("AMBIGUOUS")
elif p==1:
    print("MMYY")
elif q==1:
    print("YYMM")
else:
    print("NA")

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

Solution (Python):
s=int(input())
fa=0
fb=0
if s//100>12 or s//100==0:fa+=1
if s%100>12 or s%100==0:fb+=1
if fa==1 and fb==1:print('NA')
elif fa==1 and fb==0:print('YYMM')
elif fa==0 and fb==1:print('MMYY')
else:print('AMBIGUOUS')

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

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

Solution (Python):
s = input()

def is_month(n):
    if 1 <= int(n) <= 12:
        return True

if is_month(s[:2]) and is_month(s[2:]):
    print("AMBIGUOUS")
elif is_month(s[:2]) and not is_month(s[2:]):
    print("MMYY")
elif not is_month(s[:2]) and  is_month(s[2:]):
    print("YYMM")
else:
    print("NA")

Solution (Python):
S = input()
mae = int(S[:2])
ushiro = int(S[-2:])


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

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

YYMM=False
MMYY=False

if 0<=b<=99 and 1<=a<=12:
    YYMM=True

if 1<=b<=12 and 0<=a<=99:
    MMYY=True

if YYMM and MMYY:
    print('AMBIGUOUS')
elif YYMM and not MMYY:
    print('YYMM')
elif not YYMM and MMYY:
    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")
    quit()
if (a>12 or a<1)and (b>12 or b<1):
    print("NA")
    quit()
if 1<=a<=12:
    print("MMYY")
    quit()
if 1<=b<=12:
    print("YYMM")
    quit()

Solution (Python):
S = input()

x, y = int(S[:2]), int(S[2:])
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):
S=input()
mae=int(S[0]+S[1])
usiro=int(S[2]+S[3])

maeMM = True if 0< mae and mae<13 else False
usiroMM =True if 0< usiro and usiro<13 else False

if maeMM and usiroMM:
    print('AMBIGUOUS')
elif maeMM:
    print('MMYY')
elif usiroMM:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()

jf, jl = 0 < int(S[:2]) <= 12, 0 < int(S[2:]) <= 12

if jf and jl:
    print('AMBIGUOUS')
elif jf and not jl:
    print('MMYY')
elif not jf and jl:
    print('YYMM')
else:
    print('NA')

Solution (Python):


import math
import re

def main(params):
    n = list(params[0])
    f = n[0] + n[1]
    s = n[2] + n[3]

    try:
        if (int(f) >= 1 and int(f) <= 12) and (int(s) == 0 or int(s) > 12):
            print "MMYY"
        elif (int(f) >= 1 and int(f) <= 12) and (int(f) >= 1 and int(f) <= 12):
            print "AMBIGUOUS"
        elif (int(s) >= 1 and int(s) <= 12) and (int(f) == 0 or int(f) > 12):
            print "YYMM"
        else:
            print "NA"
    except:
        print "NA"

if __name__ == "__main__":
    cnt = 1 
    params = []
    for i in range(cnt):
        param = raw_input()
        params.append(param)
    main(params)

Solution (Python):
S = input()

head = S[0] + S[1]
tail = S[2] + S[3]

is_head_month = False
is_tail_month = False

if (int(head) <= 12 and int(head) != 0) :
    is_head_month = True

if (int(tail) <= 12 and int(tail) != 0) :
    is_tail_month = True

if (is_head_month == True and is_tail_month == True) :
    print("AMBIGUOUS")
elif (is_head_month == True and is_tail_month == False) :
    print("MMYY")
elif (is_head_month == False and is_tail_month == True) :
    print("YYMM")
else :
    print("NA")

Solution (Python):
S = input()

a = S[:2]
b = S[2:]

a = int(a)
b = int(b)

x = False
y = False

if 0 < a and a < 13:
    x = True

if 0 < b and b < 13:
    y = True

if x and y:
    print("AMBIGUOUS")
elif x:
    print("MMYY")
elif y:
    print("YYMM")
else:
    print("NA")

Solution (Python):

"""
B - YYMM or MMYY
https://atcoder.jp/contests/abc126/tasks/abc126_b

"""
import sys


def solve(S):
    is_YYMM = True
    is_MMYY = True
    first = int(S[:2])
    second = int(S[2:])
    if second > 12:
        is_YYMM = False
    if first > 12:
        is_MMYY = False
    if first == 0:
        is_MMYY = False
    if second == 0:
        is_YYMM = False

    if (not is_YYMM) and (not is_MMYY):
        return 'NA'
    if not is_YYMM:
        return 'MMYY'
    if not is_MMYY:
        return 'YYMM'
    return 'AMBIGUOUS'


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
inp=int(input())
top=inp//100
bot=inp-top*100
if top>=1 and top<=12:
  if bot>=1 and bot<=12:
  	print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if bot>=1 and bot<=12:
  	print('YYMM')
  else:
    print('NA')

Solution (Python):
S = input()

if S[0:2] > "12":
    if "01" <= S[2:4] <= "12":
        print("YYMM")
    else:
        print("NA")

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

else:
    print("NA")

Solution (Python):
S = input()

eligible_months = set(range(1,13))

first = int(S[:2])
second = int(S[-2:])

if first in eligible_months:

    if second in eligible_months:

        print('AMBIGUOUS')

    else:

        print('MMYY')

else:

    if second in eligible_months:

        print('YYMM')

    else:

        print('NA')

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

m1 = (1 <= s1 <= 12)
m2 = (1 <= s2 <= 12)

if m1 and m2:
    print('AMBIGUOUS')
elif m1 and not m2:
    print('MMYY')
elif m2 and not m1:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()

mae = int(S[0:2])
ushiro = int(S[2:4])

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

Solution (Python):
def main():
	S = input()
	SL = int(S[0:2])
	SR = int(S[2:4])
	lm = False
	rm = False
	if 0 < SL < 13:
		lm = True
	if 0 < SR < 13:
		rm = True
	if lm and rm:
		print("AMBIGUOUS")
	elif lm and not rm:
		print("MMYY")
	elif not lm and rm:
		print("YYMM")
	else:
		print("NA")


if __name__ == '__main__':
	main()

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

Solution (Python):
S = input()
mae = False
ushiro = False
if int(S[2:4]) <= 12 and int(S[2:4]) != 0:
    ushiro = True
if int(S[0:2]) <= 12 and int(S[0:2]) != 0:
    mae = True

if mae and ushiro:
    print("AMBIGUOUS")
elif mae:
    print("MMYY")
elif ushiro:
    print("YYMM")
else:
    print("NA")

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

Solution (Python):
s = input()

l = int(s[:2])
r = int(s[2:])

if 0 < l and l <= 12:
    if 0 < r and r <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < r and r <= 12:
        print('YYMM')
    else:
        print('NA')

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

f1 = s[:2]
f2 = s[2:]

def vm(s):
    if s != '00' and s <= '12':
        return True
    return False

def vd(s):
    return True

if vm(f1) and vm(f2):
    print('AMBIGUOUS')
elif vm(f1) and vd(f2):
    print('MMYY')
elif vd(f1) and vm(f2):
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()

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

Solution (Python):




def is_month(n):
    return 1 <= n <= 12


S = input().strip()
n_upper = int(S[:2])
n_lower = int(S[2:])

if is_month(n_upper) and is_month(n_lower):
    print("AMBIGUOUS")
elif is_month(n_upper):
    print("MMYY")
elif is_month(n_lower):
    print("YYMM")
else:
    print("NA")

Solution (Python):
s=input()
s1=int(s[0]+s[1])
s2=int(s[2]+s[3])
ans=['YYMM','MMYY','AMBIGUOUS','NA']
if s1==0:
  if s2==0:
    print('NA')
  elif 1<=s2<=12:
    print('YYMM')
  elif s2>=13:
    print('NA')
elif 1<=s1<=12:
  if s2==0:
    print('MMYY')
  elif 1<=s2<=12:
    print('AMBIGUOUS')
  elif s2>=13:
    print('MMYY')
elif s1>=13:
  if s2==0:
    print('NA')
  elif 1<=s2<=12:
    print('YYMM')
  elif s2>=13:
    print('NA')

Solution (Python):
S = input()
mae = int(S[:2])
ato = int(S[2:])

def my(x):
    if x == 0:
        return "y"
    if x >= 13:
        return "y"
    return "my"

t = (my(ato),my(mae))
if t==("my","my"):
    print("AMBIGUOUS")
elif t== ("y","y"):
    print("NA")
elif t== ("y","my"):
    print("MMYY")
else:
    print("YYMM")

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

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

Solution (Python):




def isMM(n):
    return 1 <= n <= 12

def main():
    
    s = input()
    s1 = int(s[:2])
    s2 = int(s[2:])
    
    if isMM(s1) and isMM(s2):
        ans = 'AMBIGUOUS'
    elif isMM(s1):
        ans = 'MMYY'
    elif isMM(s2):
        ans = 'YYMM'
    else:
        ans = 'NA'
    
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
S = input()

former = int(S[0:2])
after = int(S[2:4])


if (13 <= former or former == 0)and 1 <= after <= 12:
    print("YYMM")
elif 1 <= former <= 12 and (13 <= after or after == 0):
    print("MMYY")
elif 1 <= former <= 12 and 1 <= after <= 12:
    print("AMBIGUOUS")
else:
    print("NA")

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

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

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

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

s1_is_month = 1 <= s1 <= 12
s2_is_month = 1 <= s2 <= 12

if s1_is_month and s2_is_month:
    print('AMBIGUOUS')
elif s1_is_month:
    print('MMYY')
elif s2_is_month:
    print('YYMM')
else:
    print('NA')

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

def im(m):
    return 1 <= m and m <= 12

ay = im(y)
am = im(m)
if ay and am :
    print('AMBIGUOUS')
elif ay:
    print('MMYY')
elif am:
    print('YYMM')
else:
    print("NA")

Solution (Python):
s = input()

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

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

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

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

Solution (Python):
S = input()

a = S[:2]
b = S[2:]

if 1 <= int(a) <= 12 and 1 <= int(b) <= 12:
    print('AMBIGUOUS')
elif 0 <= int(a) <= 99 and 1 <= int(b) <= 12:
    print('YYMM')
elif 1 <= int(a) <= 12 and 0 <= int(b) <= 99:
    print('MMYY')
else:
    print('NA')

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

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

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

Solution (Python):
s=input()
s1=int(s[0:2])
s2=int(s[2:4])
s1MM=False
s2MM=False
if 1<=s1 and 12>=s1:
  s1MM=True
if 1<=s2 and 12>=s2:
  s2MM=True

if s1MM and s2MM:
  print("AMBIGUOUS")
elif s1MM:
  print("MMYY")
elif s2MM:
  print("YYMM")
else:
  print("NA")

Solution (Python):
a =input()
def pp(n):
    n = int(n)
    return 0<n<13
if pp(a[:2]) and pp(a[2:]):
    print("AMBIGUOUS")
elif not pp(a[:2]) and pp(a[2:]):
    print("YYMM")
elif pp(a[:2]) and not pp(a[2:]):
    print("MMYY")
else:
    print("NA")

Solution (Python):
S = input()

YYMM=0
MMYY=0

if int(S[2:])<=12 and int(S[2:])!=0:
    YYMM+=1
if int(S[:2])<=12 and int(S[:2])!=0:
    MMYY+=1

if YYMM==1 and MMYY!=1:
    print('YYMM')
elif YYMM!=1 and MMYY==1:
    print('MMYY')
elif YYMM==1 and MMYY==1:
    print('AMBIGUOUS')
else:
    print('NA')

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

if left == 0:
    if right == 0:
        print("NA")
    elif right < 13:
        print("YYMM")
    else:
        print("NA")
    exit()
if right == 0:
    if left < 13:
        print("MMYY")
    else:
        print("NA")
    exit()

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

Solution (Python):
S = input()

first = int(S[0:2])
last = int(S[2:4])

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

Solution (Python):



S = int(input())
mae = S//100
ato = S%100

if 1<= mae <= 12:
    if 1 <= ato <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= ato <= 12:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
S = input()
AA = int(S[:2])
BB = int(S[2:])

def check(num):
    if 1<=num<=12:
        return True
    else:
        return False
    
if check(AA) and check(BB):
    print("AMBIGUOUS")
elif check(AA):
    print("MMYY")
elif check(BB):
    print("YYMM")
else:
    print("NA")

Solution (Python):
s=input()
a=int(s[0:2])
b=int(s[2:4])
if 1<=a<=12 and 1<=b<=12:
    print('AMBIGUOUS')
elif 1<=a<=12 and not 1<=b<=12:
    print('MMYY')
elif not 1<=a<=12 and 1<=b<=12:
    print('YYMM')
elif not 1<=a<=12 and not 1<=b<=12:
    print('NA')

Solution (Python):
s = input()

def isMonth(n):
	return n <=12 and n > 0
a = isMonth(int(s[:2]))
b = isMonth(int(s[2:]))

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

Solution (Python):
s = input()
f = int(s[0:2])
l = int(s[2:])

if 1 <= f <= 12:
	if 1 <= l <= 12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 1 <= l <= 12:
		print("YYMM")
	else:
		print("NA")

Solution (Python):
S = input()

def can_be_mm(s):
    num = int(s[1])
    if s[0] == '0':
        if num != 0:
            return True
    elif s[0] == '1':
        if num >= 0 and num <= 2:
            return True
    return False

yymm = can_be_mm(S[2:])
mmyy = can_be_mm(S[:2])

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

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

f = int("".join(a[0]+a[1]))
g = int("".join(a[2]+a[3]))
if 1<= f and f <= 12:
     if 1<= g and g <= 12:
          print("AMBIGUOUS")
     else:
          print("MMYY")
elif 1<= g and g <= 12:     
     print("YYMM")
else:
     print("NA")

Solution (Python):
S = input()

def M(s):
    return s > 0 and s <= 12


S1,S2 = int(S[:2]),int(S[2:])
if M(S1) and M(S2):
    print("AMBIGUOUS")
elif M(S1):
    print("MMYY")
elif M(S2):
    print("YYMM")
else:
    print("NA")

Solution (Python):
s=input()
fst,snd=s[:2],s[2:]
def m(s_):
    if int(s_) <= 12 and int(s_) > 0:
        return True
    return False

if m(fst) and m(snd):
    print("AMBIGUOUS")
elif m(fst):
    print("MMYY")
elif m(snd):
    print("YYMM")
else:
    print("NA")

Solution (Python):
S = list(input())
for i in range(4):
    S[i] = int(S[i])


flag1 = 0
if S[0] == 1:
    if S[1] <= 2:
        flag1 = 1
if S[0] == 0:
    if S[1] != 0:
        flag1 = 1

flag2 = 0
if S[2] == 1:
    if S[3] <= 2:
        flag2 = 1
if S[2] == 0:
    if S[3] != 0:
        flag2 = 1

if flag1 == 0 and flag2 == 0:
    print("NA")
if flag1 == 1 and flag2 == 0:
    print("MMYY")
if flag1 == 0 and flag2 == 1:
    print("YYMM")
if flag1 == 1 and flag2 == 1:
    print("AMBIGUOUS")

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

Solution (Python):
S = [int(x) for x in list(input())]
f,b = S[0]*10 + S[1], S[2]*10 + S[3]

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

Solution (Python):
S = input()
y1, m1 = int(S[:2]), int(S[2:])
y2, m2 = int(S[2:]), int(S[:2])
if 1 <= m1 <= 12 and 1 <= m2 <= 12:
    print("AMBIGUOUS")
elif 1 <= m1 <= 12:
    print("YYMM")
elif 1 <= m2 <= 12:
    print("MMYY")
else:
    print("NA")

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

Solution (Python):
def main():
	s = input()
	a = int(s[:2])
	b = int(s[2:])
	x = (a == 0 or a > 12)
	y = (b == 0 or b > 12)
	if x and y:
		print("NA")
	elif not x and not y:
		print("AMBIGUOUS")
	elif x:
		print("YYMM")
	else:
		print("MMYY")
	return 0

main()

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

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


def readInts():
  return [int(s) for s in input().split(" ")]

def can_mm(n):
  return 1 <= n and n <= 12

def main():
  S = input()
  a = int(S[:2])
  b = int(S[2:])
  if can_mm(a) and can_mm(b):
    print("AMBIGUOUS")
  elif can_mm(a):
    print("MMYY")
  elif can_mm(b):
    print("YYMM")
  else:
    print("NA")

if __name__ == "__main__":
  main()

Solution (Python):
a,b,c,d=input()
n,m=int(a+b),int(c+d)
if((1<=m<=12) and (1<=n<=12)):
    print('AMBIGUOUS')
elif((1<=m<=12)):
    print('YYMM')
elif((1<=n<=12)):
    print('MMYY')
else:
    print('NA')

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

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

B = int(s[2:])

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()
a = [int(S[:2]), int(S[2:])]
b = [1<=c and c<=12 for c in a]

if b[0] and b[1]:
    print('AMBIGUOUS')
if b[0] and not b[1]:
    print('MMYY')
if not b[0] and b[1]:
    print('YYMM')
if not b[0] and not b[1]:
    print('NA')

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

Solution (Python):


import sys


s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    a = int(S[:2])
    b = int(S[2:])
    ma = 1 <= a and a <= 12
    mb = 1 <= b and b <= 12
    if ma and mb:
        print('AMBIGUOUS')
    elif ma:
        print('MMYY')
    elif mb:
        print('YYMM')
    else:
        print('NA')

main()

Solution (Python):



def solve():
    s = input()
    f, t = s[:2], s[2:]
    YYMM = 0 <= int(f) <= 99 and 1 <= int(t) <= 12
    MMYY = 0 <= int(t) <= 99 and 1 <= int(f) <= 12
    if YYMM and MMYY:
        print('AMBIGUOUS')
    elif YYMM:
        print('YYMM')
    elif MMYY:
        print('MMYY')
    else:
        print('NA')

if __name__=="__main__":
    solve()

Solution (Python):
S = input()
A = int(S[0:2])
B = int(S[2:4])

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

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

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

Solution (Python):
S = input()

x1 = int(S[0:2])
x2 = int(S[2:4])

if 1 <= x1 <= 12:
    month1 = True
else:
    month1 = False

if 1 <= x2 <= 12:
    month2 = True
else:
    month2 = False

if month1 and month2:
    out = "AMBIGUOUS"
elif month1 and (not month2):
    out = "MMYY"
elif (not month1) and month2:
    out = "YYMM"
else:
    out = "NA"

print(out)

Solution (Python):
import sys,collections as cl,bisect as bs
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n = list(input())

a = n[0:2]

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

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

Solution (Python):
line = input()

MM_set = set([i+1 for i in range(12)])

first = int(line[:2])
second = int (line[2:])
if first in MM_set and second in MM_set:
  print("AMBIGUOUS")
elif first in MM_set and second not in MM_set:
  print("MMYY")
elif not first in MM_set and second in MM_set:
  print("YYMM")
else:
  print("NA")

Solution (Python):
S = input()

YYMM = 1 <= int(S[2:]) <= 12
MMYY = 1 <= int(S[:2]) <= 12

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

Solution (Python):



def main():
    s = input()
    f = int(s[:2])
    l = int(s[2:])

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


if __name__ == '__main__':
    main()

Solution (Python):

s = input()

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


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

Solution (Python):

S=input()

if S[0]=="0":
    a=int(S[1])
else:
    a=int(S[:2])
if S[2]=="0":
    b=int(S[3])
else:
    b=int(S[2:])

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

Solution (Python):
s = input()
upper = int(s[0:2])
lower = int(s[2:4])

isYYMM = False
isMMYY = False
if 1 <= lower and lower <= 12  : 
    isYYMM = True
if 1 <= upper and upper <= 12 : 
    isMMYY = True

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

Solution (Python):
S=input()
x=int(S[:2])
y=int(S[2:])

a1=0
a2=0
if 0<=x<=99 and 1<=y<=12:
    a1=1
if 1<=x<=12 and 0<=y<=99:
    a2=1
if a1==1 and a2==1:
    print('AMBIGUOUS')
elif a1==1:
    print('YYMM')
elif a2==1:
    print('MMYY')
else:
    print('NA')

Solution (Python):
months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
input_line = input()
if (''.join(input_line[:2]) in months) and (''.join(input_line[2:]) in months):
    print('AMBIGUOUS')
elif ''.join(input_line[:2]) in months:
    print('MMYY')
elif ''.join(input_line[2:]) in months:
    print('YYMM')
else:
    print('NA')

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


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

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

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

A = int(S[0]) * 10 + int(S[1])
B = int(S[2]) * 10 + int(S[3])

if A > 0 and A <= 12:
    res_A = True
else:
    res_A = False

if B > 0 and B <= 12:
    res_B = True
else:
    res_B = False

if res_A and res_B:
    print("AMBIGUOUS")
elif res_A:
    print("MMYY")
elif res_B:
    print("YYMM")
else:
    print("NA")

Solution (Python):
S = input()

op = ["YYMM","MMYY","AMBIGUOUS","NA"]
a = int(S[0] + S[1])
b = int(S[2] + S[3])

if 1 <= a <= 12 and 1 <= b <= 12:
    print(op[2])
elif 1 <= a <= 12:
    print(op[1])
elif 1 <= b <= 12:
    print(op[0])
else:
    print(op[3])