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

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

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

Solution (Python):
S = input()
if (1 <= int(S[0:2]) <= 12):
  f = "M"
else:
  f = "Y"
if (1 <= int(S[2:4]) <= 12):
  b = "M"
else:
  b = "Y"
if(f=="Y")and(b=="M"):
  print("YYMM")
elif(f=="M")and(b=="Y"):
  print("MMYY")
elif(f=="M")and(b=="M"):
  print("AMBIGUOUS")
else:
  print("NA")

Solution (Python):
line = input()

digits = '0123456789'
chars = list(map(lambda x:digits.find(x), line))

def isMM(part):
    num = part[0] * 10 + part[1]
    if 0 < num and num < 13:
        return True

def test(chars):
    if -1 in chars:
        return 3
    partA = chars[0:2]
    partB = chars[2:4]
    
    resultA = isMM(partA)
    resultB = isMM(partB)
    
    if resultA is True:
        if resultB is True:
            return 2
        else:
            return 1
    else:
        if resultB is True:
            return 0
        else:
            return 3
    
    
result = test(chars)
if result == 0:
    print("YYMM")
elif result == 1:
    print("MMYY")
elif result == 2:
    print("AMBIGUOUS")
elif result == 3:
    print("NA")

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

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

if a >= 13 and b >= 13:
    print("NA")
elif 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()
a=int(s[0])*10+int(s[1])
b=int(s[2])*10+int(s[3])
if 1<=a<=12 and 1<=b<=12:
    print("AMBIGUOUS")
elif 1<=b<=12:
    print("YYMM")
elif 1<=a<=12:
    print("MMYY")
else:
    print("NA")

Solution (Python):
S = input()
pre = int(S[0:2])
af = int(S[2:4])
if 1 <= pre <= 12:
    preM = 1
else:
    preM = 0
if 1 <= af <= 12:
    afM = 1
else:
    afM = 0
if preM == 1:
    if afM == 1:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if afM == 1:
        ans = "YYMM"
    else:
        ans = "NA"
print(ans)

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

s1 = int(S[0] + S[1])
s2 = int(S[2] + S[3])

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

Solution (Python):
def B():
    
    S = input()
    ans = ['YYMM','MMYY','AMBIGUOUS','NA']
    YYMM = False
    MMYY = False
    AMB = False
    NA = False
    
    Sxx__ = S[0] + S[1]
    S__xx = S[2] + S[3]
    M = [str(i) if i >9 else '0' + str(i) for i in range(1,13)]
    Y = [str(i) if i >9 else '0' + str(i) for i in range(0,99)]
    if Sxx__ in M and S__xx in Y:
        MMYY = True
    if Sxx__ in Y and S__xx in M:
        YYMM = True

    if YYMM is True and MMYY is True:
        print(ans[2])
    elif YYMM is False and MMYY is False:
        print(ans[3])
    elif YYMM is True:
        print(ans[0])
    elif MMYY is True:
        print(ans[1])
        
 
if __name__ == '__main__':
    B()

Solution (Python):
S = input()

f = int(S[0]+S[1])
s = int(S[2]+S[3])

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

Solution (Python):
S = input()
L = int(S[:2])
R = int(S[2:])

if L!=0 and R!= 0 and L <=12 and R<=12:
    print("AMBIGUOUS")
elif L!=0 and L<=12:
    print("MMYY")
elif R!=0 and R<=12:
    print("YYMM")
else:
    print("NA")

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

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

MM = [1,2,3,4,5,6,7,8,9,10,11,12]

if S1 in MM and S2 in MM:
    print("AMBIGUOUS")
if S1 in MM and S2 not in MM:
    print("MMYY")
if S1 not in MM and S2 in MM:
    print("YYMM")
if S1 not in MM and S2 not in MM:
    print("NA")

Solution (Python):
import sys

s = input()

first_half = int(s[0:2])
second_half = int(s[2:4])

if 1 <= first_half and first_half <= 12 :
  if second_half == 0 or 13 <= second_half:
    print("MMYY")
  else:
    print("AMBIGUOUS")
else:
  if second_half == 0 or 13 <= second_half:
    print("NA")
  else:
    print("YYMM")

Solution (Python):
miu = input()

sella = miu[0:2]
miu = miu[2:4]

delphine = [0,0]

if 1 <= int(sella) and int(sella) <= 12:
	delphine[0] += 1


if 1 <= int(miu) and int(miu) <= 12:
	delphine[1] += 1

if sum(delphine) == 0:
	print("NA")
elif sum(delphine) == 2:
	print("AMBIGUOUS")

elif delphine[0] == 1:
	print("MMYY")
else:
	print("YYMM")

Solution (Python):
s = input()
front = int(s[0:2])
back = int(s[2:4])


yymm = False
mmyy = False


if 1 <= front <= 12:
    if 0 <= back <= 99:
        mmyy = True

if 1 <= back <= 12:
    if 0 <= front <= 99:
        yymm = True

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

Solution (Python):
S = int(input())
YY = S // 100
MM = S % 100

if YY <= 12 and MM <= 12 and MM > 0 and YY > 0:
    print('AMBIGUOUS')
elif MM <= 12 and MM > 0:
    print('YYMM')
elif MM > 12 and YY <= 12:
    print('MMYY')
elif MM == 0 and YY <= 12 and YY > 0:
    print('MMYY')
else:
    print('NA')

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

Solution (Python):

S=int(input())
y=S//100
m=S%100



if y>=13 and m>=13:
    print("NA")
elif y>=13 and m!=0 :
    print("YYMM")
elif m>=13 and y!=0 :
    print("MMYY")
elif 1<=m and 12>=m and y==0 :
    print("YYMM")
elif 1<=y and 12>=y and m==0 :
    print("MMYY")
elif m==0 or y==0:
    print("NA")
else:
    print("AMBIGUOUS")

Solution (Python):
S = input()

s_1 = int(S[0:2])
s_2 = int(S[2:])

YYMM = False
MMYY = False

if 1<=s_2<=12:
    YYMM = True
if 1<=s_1<=12:
    MMYY = True
    
if YYMM and MMYY:
    print('AMBIGUOUS')
elif YYMM:
    print('YYMM')
elif MMYY:
    print('MMYY')
else:
    print('NA')

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

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

Solution (Python):
S=input()
AA=int(S[:2])
BB=int(S[2:])
print(["NA","MMYY","YYMM","AMBIGUOUS"][
    (1<=AA<=12)+2*(1<=BB<=12)
    ])

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

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):
def j(cont):
    if int(cont)>=1 and int(cont)<=12:
        return True
    else:
        return False

s = input()
l,r = s[:2],s[2:]
if j(l) is True and j(r) is True:
    print('AMBIGUOUS')
elif j(l) is False and j(r) is False:
    print('NA')
elif j(l) is False and j(r) is True:
    print('YYMM')
else:
    print('MMYY')

Solution (Python):
S=input()
mae=S[:2]
ato=S[2:]
mon_list=("01","02","03","04","05","06","07","08","09","10","11","12")
test=0
if mae in mon_list:
  test=test+1
if ato in mon_list:
  test=test+3

if test==0:
  print("NA")
if test==1:
  print("MMYY")
if test==3:
  print("YYMM")
if test==4:
  print("AMBIGUOUS")

Solution (Python):
s = input()

s1 = s[:2]
s2 = s[2:]

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

s1MM = False
s2MM = False

if s1 in MM:
    s1MM = True

if s2 in MM:
    s2MM = True


if s1MM & s2MM:
    print('AMBIGUOUS')
elif s1MM:
    print('MMYY')
elif s2MM:
    print('YYMM')
else:
    print('NA')

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

FORMAT_S = ['AMBIGUOUS', 'YYMM', 'MMYY', 'NA']
format_flag = [True, True, True, True]

if A == 0 or 12 < A:
    format_flag[0] = False
    format_flag[2] = False
if B == 0 or 12 < B:
    format_flag[0] = False
    format_flag[1] = False

for i in range(4):
    if format_flag[i] == True:
        print(FORMAT_S[i])
        break

Solution (Python):
s = input()

top = int(s[0]) * 10 + int(s[1])
btm = int(s[2]) * 10 + int(s[3])


is_m = lambda n: 0 < n < 13

if is_m(top) and is_m(btm):
    print("AMBIGUOUS")
elif is_m(top):
    print("MMYY")
elif is_m(btm):
    print("YYMM")
else:
    print("NA")

Solution (Python):


"""
Created on Fri Mar  1 19:29:34 2019

@author: nakamuratakayuki
"""
S = input()
S1 = int(S[0:2])
S2 = int(S[2:4])

ans0 = 0
if 1 <= S2 <= 12:
    ans0 += 1
if 1 <= S1 <= 12:
    ans0 += 2
    
ans =''
if ans0 == 0:
    ans = 'NA'
if ans0 == 1:
    ans = 'YYMM'
if ans0 == 2:
    ans = 'MMYY'
if ans0 == 3:
    ans = 'AMBIGUOUS'
    
print(ans)

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

Solution (Python):
def get_format(a, b):
  if 0 < a < 13 and 0 < b < 13:
    return 'AMBIGUOUS'
  elif 0 < a < 13:
    return "MMYY"
  elif 0 < b < 13:
    return "YYMM"
  else:
    return 'NA'
 
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
print(get_format(s1, s2))

Solution (Python):
s = list(input())
YYMM = False
MMYY = False
 
if s[2] == '1':
    if (s[3] == '0') | (s[3] == '1') | (s[3] == '2'):
        YYMM = True
elif s[2] == '0':
    if s[3] != '0':
        YYMM = True
 
if s[0] == '1':
    if (s[1] == '0') | (s[1] == '1') | (s[1] == '2'):
        MMYY = True
elif s[0] == '0':
    if s[1] != '0':
        MMYY = True
 
if YYMM & MMYY:
    print("AMBIGUOUS")
elif YYMM:
    print("YYMM")
elif MMYY:
    print("MMYY")
else:
    print("NA")

Solution (Python):
t = list(map(str, input().split())) 
s=t[0]

s1=int(s[0]+s[1])
s2=int(s[2]+s[3])

b1 = (s1>=1 and s1<=12)
b2 = (s2>=1 and s2<=12)

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

Solution (Python):


import re

S = input()

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

isMonth = r'^(0[1-9]|1[0-2])$'
isYear = r'[0-9][0-9]'

if re.match(isYear, a) and re.match(isMonth, b) and re.match(isMonth, a) and re.match(isYear, b):
	print('AMBIGUOUS')
elif re.match(isYear, a) and re.match(isMonth, b):
	print('YYMM')
elif re.match(isMonth, a) and re.match(isYear, b):
	print('MMYY')
else:
	print('NA')

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

Solution (Python):
s = input()

x = int(s[0:2])
y = int(s[2:])

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

Solution (Python):
import sys
import os

s=list(input())
a=(s[0],s[1])
N1=int(a[0])*10+int(a[1])
b=(s[2],s[3])
N2=int(b[0])*10+int(b[1])

if N1 > 12 or N1 == 0:
    if N2 > 12 or N2 == 0:
        print("NA")
    else:
        print("YYMM")
else:
    if N2 > 12 or N2 == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Solution (Python):
import sys

lines = sys.stdin.readlines()
input_list = list(lines[0].rstrip())
int12 = int("".join([input_list[0],input_list[1]]))
int34 = int("".join([input_list[2],input_list[3]]))
if 1 <= int12 <= 12:
  if 1 <= int34 <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= int34 <= 12:
    print("YYMM")
  else:
    print("NA")

Solution (Python):
s = input()

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

def isYear(x):
    return x >= 0

def isMonth(x):
    return x > 0 and x <= 12

if(isYear(a) and isMonth(a) and isYear(b) and isMonth(b)):
    print("AMBIGUOUS")
elif(isYear(a) and isMonth(b)):
    print("YYMM")
elif(isMonth(a) and isYear(b)):
    print("MMYY")
else:
    print("NA")

Solution (Python):

S = input()
str_1 = int(S[:2])
str_2 = int(S[2:])

def judge_month(i):
    if i >= 1 and i <= 12:
        judge = True
    else:
        judge = False
    return judge
judge_1 = judge_month(str_1)
judge_2 = judge_month(str_2)
if judge_1 and judge_2:
    print("AMBIGUOUS")
elif judge_1:
    print("MMYY")
elif judge_2:
    print("YYMM")
else:
    print("NA")

Solution (Python):
S = int(input())
l = S // 100
r = S % 100

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

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

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

    az = int(a) == 0
    ap = 0 < int(a) < 100
    am = 0 < int(a) < 13
    bz = int(b) == 0

    bp = 0 < int(b) < 100
    bm = 0 < int(b) < 13
    if ap and am and bp and bm:
        print('AMBIGUOUS')
    elif ap and am and (bz or bp) and not bm:
        print('MMYY')
    elif (az or ap) and not am and bp and bm:
        print('YYMM')
    else:
        print('NA')


main()

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

a_month = False
b_month = False

if(a > 0) and (a <= 12):
    a_month = True

if(b > 0) and (b <= 12):
    b_month = True
    
if (a_month == False) and (b_month == False):
    print('NA')
    
elif (a_month == True) and (b_month == True):
    print('AMBIGUOUS')
    
elif (a_month == True):
    print('MMYY')
    
else:
    print('YYMM')

Solution (Python):
S = input()
part0 = int(S[0:2])
part1 = int(S[2:])

def ismonth(number):
    if number > 0 and number < 13:
            return True
    return False

if ismonth(part0) and ismonth(part1):
        print("AMBIGUOUS")
elif ismonth(part0):
        print("MMYY")
elif ismonth(part1):
        print("YYMM")
else:
        print("NA")

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

Solution (Python):
def is_month(number):
    if 0 < number < 13:
        return True
    return False


s = input()
if len(s) != 4:
    print("NA")
elif not s.isdecimal():
    print("NA")
else:
    before = int(s[0:2])
    after = int(s[2:])
    is_before_month = 0  
    is_after_month = 0
    if is_month(before):
        is_before_month = 1
    if is_month(after):
        is_after_month = 1
    
    if is_before_month == 0:
        if is_after_month == 0:
            
            print("NA")
        else:
            print("YYMM")
    else:
        if is_after_month == 1:
            
            print("AMBIGUOUS")
        else:
            print("MMYY")

Solution (Python):
a = input()
a1 = int(a[:2])
a2 = int(a[2:])
b1 = False
b2 = False
if 1 <= a1 <= 12:
    b1 = True
    
if 1 <= a2 <= 12:
    b2 = True

if b1 and b2:
    print('AMBIGUOUS')
    
elif b1:
    print('MMYY')

elif b2:
    print('YYMM')

else:
    print('NA')

Solution (Python):
Q = int(input())
Qa = Q//100
Qb = Q%100
if 1 <= Qa <= 12:
    if Qb >12:
        print("MMYY")
    elif 1 <=Qb <= 12:
        print("AMBIGUOUS")
    elif Qb == 0:
        print("MMYY")

elif Qa > 12:
    if 1 <=Qb <=12 :
        print("YYMM")
    elif Qb >12:
        print("NA")
    elif Qb == 0:
        print("NA")

elif Qa ==0:
    if(1<= Qb <=12):
        print("YYMM")

    elif(Qb ==0):
        print("NA")

    elif(Qb >12):
        print("NA")

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

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

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

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

Solution (Python):

s = input()
state = -1
a = int(s[0])*10+int(s[1])
c = int(s[2])*10+int(s[3])
state="NA"
if a < 13 and a > 0:
  state = "MMYY"
if c < 13 and c > 0:
  if state == "MMYY":
    state = "AMBIGUOUS"
  else:
    state = "YYMM"
print(state)

Solution (Python):
from sys import stdin

def main():
    S = int(input())

    n1, n2 = divmod(S, 100)
    flag = [0, 0]
    if 0 < n1 <= 12:
        flag[0] = 1
    if 0 < n2 <= 12:
        flag[1] = 1

    if sum(flag) == 1:
        if flag[0]:
            print('MMYY')
        else:
            print('YYMM')
    elif sum(flag) == 0:
        print('NA')
    else:
        print('AMBIGUOUS')

input = lambda: stdin.readline()
main()

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

if 1 <= left <= 12:
    left_jd = 1
else:
    left_jd = 0

if 1 <= right <= 12:
    right_jd = 1
else:
    right_jd = 0

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

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

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

Solution (Python):
s = input()

i = s[0:2]
j = s[2:4]

yymm_flag = True
mmyy_flag = True


if int(j) > 12 or int(j) == 0:
  yymm_flag = False


if int(i) > 12 or int(i) == 0:
  mmyy_flag = False

if yymm_flag and mmyy_flag:
  print('AMBIGUOUS')

elif not yymm_flag and not mmyy_flag:
  print('NA')

elif yymm_flag:
  print('YYMM')

elif mmyy_flag:
  print('MMYY')

Solution (Python):






S =list(input())





if int("".join(S[:2])) > 12 or int("".join(S[:2])) == 0:
    if int("".join(S[2:])) > 12 or int("".join(S[2:])) == 0:
        print("NA")
    else:
        print("YYMM")
elif int("".join(S[:2])) > 0:
    if int("".join(S[2:])) > 12 or int("".join(S[2:])) == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Solution (Python):
S=input()
prev=int(S[:2])
aft=int(S[2:])

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

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

s = input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])

if 1 <= 10*a+b <=12:
  if 1 <= 10*c+d <=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= 10*c+d <=12:
      print('YYMM')
  else:
      print('NA')

Solution (Python):
s = input().strip()
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()

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

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

Solution (Python):
import sys
input=sys.stdin.readline
def ch(s):
  if s == '10':
    return int(s)
  elif s == '00':
    return 0
  elif 2 > s.count('0') > 0:
    return int(s.replace('0',''))
  elif s.count('0') == 2:
    return 0
  else:
    return int(s)

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

b = ch(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):


import sys

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


def main():
    S = i2s()
    front = int(S[:2])
    back = int(S[2:])
    if MM(front) and MM(back):
        print('AMBIGUOUS')
    elif MM(front) and not MM(back):
        print('MMYY')
    elif not MM(front) and MM(back):
        print('YYMM')
    else:
        print('NA')

def MM(num):
    return 1 <= num <= 12

main()

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

Solution (Python):

import re
import bisect
from datetime import datetime as dt
S = raw_input()
first = int(S[0]) * 10 + int(S[1])
second = int(S[2]) * 10 + int(S[3])
if 1 <= first <= 12 and 1 <= second <= 12:
    print 'AMBIGUOUS'
elif 1 <= first <= 12:
    print 'MMYY'
elif 1 <= second <= 12:
    print 'YYMM'
else:
    print 'NA'

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

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

Solution (Python):
S = input()

S1 = S[0:2]
S2 = S[2:5]

if 1 <= int(S1) <= 12:
    if 1 <= int(S2) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= int(S2) <= 12:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
number = input()
number_list = list(number)

forward = number_list[0] + number_list[1]
back = number_list[2] + number_list[3]
if int(forward) < 13 and int(forward) > 0 and int(back) < 13 and int(back) > 0:
    print("AMBIGUOUS")
elif int(forward) < 13 and int(forward) > 0:
    print("MMYY")
elif int(back) > 0 and int(back) < 13:
    print("YYMM")
else:
    print("NA")

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

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

mmyy = False
yymm = False
if 0 < a < 13:
    mmyy = True

if 0 < b < 13:
    yymm = True

if mmyy is True and yymm is False:
    print('MMYY')
elif mmyy is True and yymm is True:
    print('AMBIGUOUS')
elif mmyy is False and yymm is False:
    print('NA')
else:
    print('YYMM')

Solution (Python):
argS = input()
argS1 = int(argS[0:2])
argS2 = int(argS[2:4])

if argS1 > 0 and argS1 < 13:
  flgMM1 = True
else:
  flgMM1 = False

if argS2 > 0 and argS2 < 13:
  flgMM2 = True
else:
  flgMM2 = False

if flgMM1 == True and flgMM2 == False:
  ans = "MMYY"
elif flgMM1 == False and flgMM2 == True:
  ans = "YYMM"
elif flgMM1 == True and flgMM2 == True:
  ans = "AMBIGUOUS"
else:
  ans = "NA"

print(ans)

Solution (Python):


n=str(input())
a=int(n[:2])
b=int(n[2:])
ans="NA"
flag=0
if(a<=12 and a>=1):
    ans="MMYY"
    flag+=1
if(b<=12 and b>=1):
    ans="YYMM"
    flag+=1
if(flag==2):
    ans="AMBIGUOUS"
print(ans)

Solution (Python):
n = int(input())
a = n // 100
b = n % 100
if 1 <= a and a <=12:
    if 1 <= b and b <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= b and b <= 12:
        print('YYMM')
    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 (not 1 <= A <= 12) and(not 1 <= B <= 12):
    print("NA")
elif (1 <= A <= 12) and (not 1 <= B <= 12):
    print("MMYY")
else:
    print("YYMM")

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

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

Solution (Python):

import sys

def main():
    s = input()

    head = int(s[:2])
    tail = int(s[2:])

    if head > 0 and head <= 12:
        
        if tail > 0 and tail <= 12:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    elif tail > 0 and tail <= 12:
        
        if head > 0 and head <= 12:
            print('AMBIGUOUS')
        else:
            print('YYMM')
    else:
        print('NA')

if __name__ == '__main__':
    main()

Solution (Python):
s = input().strip()
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 = list(input())
Y = 0
M = 0
intS = []
for i in range(len(s)):
    intS.append(int(s[i]))



if 0 < 10*intS[0]+intS[1] <= 12:
    M = 1

if 0 < 10*intS[2]+intS[3] <= 12:
    Y = 1

if M == 1 and Y == 0:
    print("MMYY")

elif M == 0 and Y == 1:
    print("YYMM")

elif M == 1 and Y == 1:
    print("AMBIGUOUS")

else:
    print("NA")

Solution (Python):
a = input()

former = a[:2]
latter = a[2:]

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

if(former in months and latter in months):
	print('AMBIGUOUS')
elif(former in months and latter not in months):
	print('MMYY')
elif(former not in months and latter in months):
	print('YYMM')
elif(former not in months and latter not in months):
	print('NA')

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

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

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

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

first = int(c[0]+c[1])
last = int(c[2]+c[3])

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

Solution (Python):
def decide(a, b):
    a_is_month = False
    b_is_month = False

    if a >= 1 and a <= 12:
        a_is_month = True

    if b >= 1 and b <= 12:
        b_is_month = True

    if a_is_month and b_is_month:
        print("AMBIGUOUS")
    elif a_is_month and not b_is_month:
        print("MMYY")
    elif b_is_month and not a_is_month:
        print("YYMM")
    else:
        print("NA")

s = input()

f, e = s[:2], s[2:]

decide(int(f), int(e))

Solution (Python):
def yymm(s):
    a = s[:2]
    b = s[2:]
    if (int(a)<=12 and int(a)>=1) and (int(b)<=12 and int(b)>=1):
        return 'AMBIGUOUS'
    if (int(a)<=12 and int(a)>=1) and (int(b)>12 or int(b)<1):
        return 'MMYY'
    if (int(b)<=12 and int(b)>=1) and (int(a)>12 or int(a)<1):
        return 'YYMM'
    else:
        return 'NA'
s = input()
print(yymm(s))

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

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

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

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

a, b = int(str(''.join(S[:2]))), int(str(''.join(S[2:])))
if a == 0 and b == 0:
  print('NA')
elif a == 0 and b <= 12:
  print('YYMM')
elif a <= 12 and b == 0:
  print('MMYY')
elif a == 0 and b > 12:
  print('NA')
elif b == 0 and a > 12:
  print('NA')
elif a > 12 and b > 12:
  print('NA')
elif a <= 12 and b <= 12:
  print('AMBIGUOUS')
elif a <= 12 and b > 12:
  print('MMYY')
elif a > 12 and b <= 12:
  print('YYMM')
else:
  print('NA')