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 = s[:2]
b = s[2:]
month=range(1,13)
m = []
for i in month:
    m_s = str(i)
    if i<9:
        m_s = "0" + m_s
    m.append(m_s)

isM_a = a in m 
isM_b = b in m 

if isM_a:
    if isM_b:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if isM_b:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
s = input()

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

y = False
m = False

if 1 <= top <= 12:
    m = True
if 1 <= bot <= 12:
    y = True

if y and m:
    print('AMBIGUOUS')
elif not y and m:
    print('MMYY')
elif y and not m:
    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 a>=1 and a<=12:
    if b>=1 and b<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if b>=1 and b<=12:
        print("YYMM")
    else:
        print("NA")

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

ab = S // 100
cd = S % 100
if (ab == 0 or ab > 12):
    if 1 <= cd <= 12:
        print('YYMM')
    else:
        print('NA')
elif (cd == 0 or cd > 12):
    if 1 <= ab <= 12:
        print('MMYY')
    else:
        print('NA')
else:
    print('AMBIGUOUS')

Solution (Python):
S=input()
ym=False
my=False
if 1<=int(S[0:2])<=12:
    my=True
if 1<=int(S[2:4])<=12:
    ym=True
if my and ym:
    print('AMBIGUOUS')
elif my:
    print('MMYY')
elif ym:
    print('YYMM')
else:
    print('NA')

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





mm_like = [1 <= s <= 12 for s in [s1, s2]]


if mm_like == [True, False]:
    print("MMYY")
elif mm_like == [False, True]:
    print("YYMM")
elif mm_like == [True, True]:
    print("AMBIGUOUS")
elif mm_like == [False, False]:
    print("NA")

Solution (Python):
s = list(input())
f = int(''.join(s[0:2]))
b = int(''.join(s[2:]))
if f == 0:
    if b == 0:
        print('NA')
    elif b > 13:
        print('NA')
    else:
        print('YYMM')
elif b == 0:
    if f > 13:
        print('NA')
    else:
        print('MMYY')
elif 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()
a = int(S[:2])
b = int(S[2:])

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

if isMM(a):
    if isMM(b):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if isMM(b):
        print('YYMM')
    else:
        print('NA')

Solution (Python):





def main():
    s = input()
    a = int(s[:2])
    b = int(s[2:])
    if b == 0:
        if a > 12 or a == 0:
            print("NA")
        else:
            print("MMYY")
    elif b > 12:
        if a > 12 or a == 0:
            print("NA")
        else:
            print("MMYY")
    else:
        if a > 12 or a == 0:
            print("YYMM")
        else:
            print("AMBIGUOUS")


if __name__ == '__main__':
    main()

Solution (Python):
s=int(input())
a=s//100
b=s-a*100
res=0
wes=0
if a==0 or a>12:
    res=1
if b==0 or b>12:
    wes=1
if res==1 and wes==1:
    print("NA")
if res==0 and wes==1:
    print("MMYY")
if res==1 and wes==0:
    print("YYMM")
if res==0 and wes==0:
    print("AMBIGUOUS")

Solution (Python):
S = input()

u = S[0] + S[1]
l = S[2] + S[3]

u = int(u)
l = int(l)

if (0 < u <= 12) :
	if (0 < l <= 12) : 
		print ("AMBIGUOUS")
	else:
		print ("MMYY")
else:
	if (0 < l <= 12) :
		print ("YYMM")
	else:
		print ("NA")

Solution (Python):
s=input()

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



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

ans=""
if a in mo:
  if b in mo:
    ans="AMBIGUOUS"
  else:
    ans="MMYY"
else:
  if b in mo:
    ans="YYMM"
  else:
    ans="NA"
print(ans)

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

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

if __name__ == '__main__':
    main()

Solution (Python):


S = raw_input()

if 0 < int(S[0:2]) < 13:
    if  0 < int(S[2:4]) < 13:
        print "AMBIGUOUS"
    else:
        print "MMYY"
else:
    if  0 < int(S[2:4]) < 13:
        print "YYMM"
    else:
        print "NA"

Solution (Python):

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

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

is_s0 = 1 <= s0 and s0 <= 12
is_s1 = 1 <= s1 and s1 <= 12

if is_s0==True and is_s1==True:
    print('AMBIGUOUS')
elif is_s0==True and is_s1==False:
    print('MMYY')
elif is_s0==False and is_s1==True:
    print('YYMM')
else:
    print('NA')

Solution (Python):

import sys


def solve(S: str):
    p1 = int(S[:2])
    p2 = int(S[2:])

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

    return



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

if __name__ == '__main__':
    main()

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




def withinMonths(num):
  if (num >= 1 and num <= 12):
    return True
  else:
    return False

if (withinMonths(front) and withinMonths(back)):
  print("AMBIGUOUS")
elif (withinMonths(front) and not withinMonths(back)):
  print("MMYY")
elif (not withinMonths(front) and withinMonths(back)):
  print("YYMM")
else:
  print("NA")

Solution (Python):

S = input()

mae = S[:2]
ato = S[-2:]

is_MM = (int(mae) >= 1 and int(mae) <= 12) * 10 + (int(ato) >= 1 and int(ato) <= 12)

if is_MM == 11:
  print('AMBIGUOUS')
elif is_MM == 10:
  print('MMYY')
elif is_MM == 1:
  print('YYMM')
else:
  print('NA')

Solution (Python):

import re


def mm(s):
    return re.match(r'01|02|03|04|05|06|07|08|09|11|12', s)


def solv(s):
    a = s[0:2]
    b = s[2:]
    if mm(a):
        if mm(b):
            return 'AMBIGUOUS'
        else:
            return 'MMYY'
    else:
        if mm(b):
            return 'YYMM'
        else:
            return 'NA'


if __name__ == '__main__':

    s = input()
    ans = solv(s)

    print(ans)

Solution (Python):

"""
Created on Sun May 19 21:11:48 2019

@author: Yamazaki Kenichi
"""

S = input()

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

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

Solution (Python):
S = input()

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

ans = "NA"
if YYMM and MMYY:
    ans = "AMBIGUOUS"
elif YYMM:
    ans = "YYMM"
elif MMYY:
    ans = "MMYY"
print(ans)

Solution (Python):
i=input()
l,m=map(int,[i[:2],i[2:]])
my=int(1<=l and l<=12)
ym=int(1<=m and m<=12)<<1
print(["NA","MMYY","YYMM","AMBIGUOUS"][my+ym])

Solution (Python):



s = input()


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


aY=0
bY=0
aM=0
bM=0
if 1 <= a <= 12:
    aM=1
if 1 <= b <= 12:
    bM=1

if a==0:

    if bM==1:
        print("YYMM")
    else:
        print("NA")
elif b==0:

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

Solution (Python):
s=input()

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

if 1 <= int(s1) <= 12 and 1 <= int(s2) <= 12:
  print('AMBIGUOUS')
elif 1 <= int(s2) <= 12 and not 1 <= int(s1) <= 12:
  print('YYMM')
elif 1 <= int(s1) <= 12 and not 1 <= int(s2) <= 12:
  print('MMYY')
else:
  print('NA')

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
input = sys.stdin.readline
 


 
def main():
	
	S = input()
	S = S[:-1]
	S = list(S)

	fst_han = 0
	fst_str = S[:2]
	tmp = ""
	for i in fst_str:
		tmp += i
	fst = int(tmp)

	snd_han = 0
	snd_str = S[2:]
	tmp = ""
	for i in snd_str:
		tmp += i
	snd = int(tmp)

	if fst > 0 and fst < 13:
		fst_han = 1
	if snd > 0 and snd < 13:
		snd_han = 1
	
	if fst_han == 1 and snd_han == 1:
		print("AMBIGUOUS")
	elif fst_han == 1 and snd_han == 0:
		print("MMYY")
	elif fst_han == 0 and snd_han == 1:
		print("YYMM")
	else:
		print("NA")
	

		

if __name__ == "__main__":
	main()

Solution (Python):
a = input()
b, c = '01' <= a[:2] <= '12', '01' <= a[2:] <= '12'

if b and c:
    answer = 'AMBIGUOUS'
elif not(b or c):
    answer = 'NA'
elif b:
    answer = 'MMYY'
elif c:
    answer = 'YYMM'
print(answer)

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

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

if 1 <= s1 <= 12:
  mmyy = True
if 1 <= s2 <= 12:
  yymm = True

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

Solution (Python):
S = input()

AA = int(S[:2])
BB = int(S[2:])

if 0 < AA and AA <= 12 and (12 < BB or BB == 0):
    print('MMYY')
elif 0 < BB and BB <= 12 and (12 < AA or AA == 0):
    print('YYMM')
elif 0 < AA and AA <= 12 and 0 < BB and BB <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

Solution (Python):
S=input()

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

Solution (Python):
s = int(input())
if 1 <= s // 100 <= 12:
    if 1 <= s % 100 <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= s % 100 <= 12:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
def main():
    s = input()
    s1, s2 = s[:2], s[2:]
    if int(s1) in range(1, 13):
        if int(s2) in range(1, 13):
            result = "AMBIGUOUS"
        else:
            result = "MMYY"
    else:
        if int(s2) in range(1, 13):
            result = "YYMM"
        else:
            result = "NA"

    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
S = input()
p = S[0:2]
q = S[2:4]

p = int(p)
q = int(q)

p_year_flag = 0
p_month_flag = 0
q_year_flag = 0
q_month_flag = 0

if 1 <= p and p <= 12:
    p_month_flag = 1

if 0 <= p and p <= 99:
    p_year_flag = 1
    
if 1 <= q and q <= 12:
    q_month_flag = 1
    
if 0 <= q and q <= 99:
    q_year_flag = 1
    
YYMM_flag = 0
MMYY_flag = 0

if p_year_flag == 1 and q_month_flag == 1:
    YYMM_flag = 1
if p_month_flag == 1 and q_year_flag == 1:
    MMYY_flag = 1
    
if YYMM_flag == 1 and MMYY_flag == 1:
    print('AMBIGUOUS')
    
elif YYMM_flag == 1:
    print('YYMM')
    
elif MMYY_flag == 1:
    print('MMYY')
    
else:
    print('NA')

Solution (Python):
def is_month(s):
    if s[0] == "1":
        if s[1] == "0" or s[1] == "1" or s[1] == "2":
            return True
    elif s[0] == "0":
        if s[1] == "0":
            return False
        else:
            return True
    return False


def is_year(s):
    return True


S = input()

s0 = S[:2]
s1 = S[2:]

is_mmyy = False
is_yymm = False
if is_month(s0) and is_year(s1):
    is_mmyy = True
if is_year(s0) and is_month(s1):
    is_yymm = True

if is_mmyy:
    if is_yymm:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if is_yymm:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
S = list(input())
S1 = ''.join(S[0:2])
S2 = ''.join(S[2:4])

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

else :
    if int(S2) >= 1 and int(S2) <= 12 :
        print('YYMM')
    else :
        print('NA')

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

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

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

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

Solution (Python):
S = input()[:4]

mae = S[:2]
ato = S[2:]

if mae.isnumeric() and ato.isnumeric():
    mae, ato = int(mae), int(ato)
    maeY, maeM, atoY, atoM = False, False, False, False
    
    if 1 <= mae <= 12:
        if  1 <= ato <= 12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    elif 1<= ato <= 12:
        print("YYMM")
    else:
        print("NA")
else:
    print("NA")

Solution (Python):
import sys


def parse(file):
    s = file.readline()
    return s,


def is_month(s):
    if (0 < int(s)) & (int(s) <= 12):
        return 1
    else:
        return 0


def main(s):
    ans = is_month(s[:2]) * 2 + is_month(s[2:])

    if ans == 0:
        return 'NA'
    elif ans == 1:
        return 'YYMM'
    elif ans == 2:
        return 'MMYY'
    elif ans == 3:
        return 'AMBIGUOUS'

    raise RuntimeError


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

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

Solution (Python):

































S = input()

first = int(S[0]) * 10 + int(S[1])
second = int(S[2]) * 10 + int(S[3])
MMYY = False
YYMM = False

if first >= 1 and first <= 12:
    if second >= 0 and second <= 99:
        MMYY = True

if second >= 1 and second <= 12:
    if first >= 0 and first <= 99:
        YYMM = True

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

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math

mod = 10**9+7

S = str(input())

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

print(ans)

Solution (Python):
S = input()

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

if a in range(1, 13):
    if b in range(1, 13):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if b in range(1, 13):
        print("YYMM")
    else:
        print("NA")

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

upper = S // 100
downer = S % 100

flag = 0
if(upper <= 12 and upper > 0):
  flag += 1

if(downer <= 12 and downer > 0):
  flag += 2  
if(flag == 0):
  print('NA')
elif(flag == 1):
  print('MMYY')
elif(flag == 2):
  print('YYMM')
else:
  print('AMBIGUOUS')

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

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

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

if s1 in li and s2 in li:
    print("AMBIGUOUS")
elif s1 in li and not s2 in li:
    print("MMYY")
elif s2 in li and not s1 in li:
    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 < b < 13:
    print('YYMM')
elif 0 < a < 13:
    print('MMYY')
else:
    print('NA')

Solution (Python):
s=int(input())
s1=int(s/100)
s2=s%100
if 0<s1<=12 and 0<s2<=12:
    print("AMBIGUOUS")
elif 0<s1<=12:
    print("MMYY")
elif 0<s2<=12:
    print("YYMM")
else:
    print("NA")

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

A = int("".join(s[:2]))
B = int("".join(s[2:]))

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

Solution (Python):
a=input()
a=[i for i in a]
x=int(a[0]+a[1])
y=int(a[2]+a[3])
cy=0
cm=0
if 0<x<13 and y<=99:
    cm+=1
if x<=99 and 0<y<13:
    cy+=1
if cy==1:
    if cm==1:
        print("AMBIGUOUS")
    else:
        print("YYMM")
elif cm==1:
    print("MMYY")
else:
    print("NA")

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

Solution (Python):
S = input()

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

s1 = S[0:2]
s2 = S[2:4]
ok1 = s1 in oklist
ok2 = s2 in oklist

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

Solution (Python):
if __name__ == '__main__':
    S = str(input())

    AA = int(S[0:2])
    BB = int(S[2:4])

    if (1 <= AA <= 12) and (1 <= BB <= 12):
        answer = "AMBIGUOUS"
    elif (AA == 0 or AA >= 13) and (1 <= BB <= 12):
        answer = "YYMM"
    elif (1 <= AA <= 12) and (BB == 0 or BB >= 13):
        answer = "MMYY"
    else:
        answer = "NA"

    print(answer)

Solution (Python):
s = input()

mae = int(s[:2])
usiro = int(s[2:4])

def is_mm(val):
    if (1<=val)and (12>=val):
        return True
    else:
        return False

is_mae = is_mm(mae)
is_usiro = is_mm(usiro)

if (is_mae is True) and (is_usiro is True):
    print('AMBIGUOUS')
elif(is_mae is False) and (is_usiro is True):
    print('YYMM')
elif(is_mae is True) and (is_usiro is False):
    print('MMYY')
elif(is_mae is False) and (is_usiro is False):
    print('NA')

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

Solution (Python):




import sys


class math:
    
    pi = 3.14159265358979323846264338

    
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

math = math()


class output:
    
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()















S = input()

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

ans = "NA"

if (0<A<13) and (0<B<13):
    ans = "AMBIGUOUS"
elif (0<A<13):
    ans = "MMYY"
elif (0<B<13):
    ans = "YYMM"

print(ans)

Solution (Python):
words = input()

first = int(words[0:2])
end= int(words[2:])

MMYY=False
YYMM=False
if(1<=first<=12):
    MMYY=True
if(1<=end<=12):
    if(1<=end<=12):
        YYMM =True

if MMYY:
    if YYMM:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if YYMM:
        print("YYMM")
    else:
        print("NA")

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

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

Solution (Python):
s = input()
left = int(s[:2])
right = int(s[2:])
left_y = False
left_m = False
right_y = False
right_m = False
if 1 <= left <= 12:
    left_m = True
if 0 <= left:
    left_y = True
if 1 <= right <= 12:
    right_m = True
if 0 <= right:
    right_y = True

mmyy = False
yymm = False
if left_m and right_y:
    mmyy = True
if left_y and right_m:
    yymm = True
if mmyy and yymm:
    print("AMBIGUOUS")
elif mmyy and yymm == False:
    print("MMYY")
elif mmyy == False and yymm:
    print("YYMM")
else:
    print("NA")

Solution (Python):


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

Solution (Python):
S = input()

j = [0, 0]
a = int(S[:2])
b = int(S[2:])


def judge(num):
    if num > 0 and num < 13:
        return True
    else:
        return False


if judge(a) and judge(b):
    print('AMBIGUOUS')
elif not judge(a) and not judge(b):
    print('NA')
elif judge(a) and not judge(b):
    print('MMYY')
elif not judge(a) and judge(b):
    print('YYMM')

Solution (Python):
S = input()
YY = int(S[0:2])
MM = int(S[2:4])

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

Solution (Python):
s=input()
ans='NA'
m=['01','02','03','04','05','06','07','08','09','10','11','12']
if s[:2] not in m and s[2:] in m:
    ans='YYMM'
elif s[:2] in m and s[2:] not in m:
    ans='MMYY'
elif s[:2] in m and s[2:] in m:
    ans='AMBIGUOUS'
print(ans)

Solution (Python):
S = input()
a = int(S[:2])
b = int(S[2:])
if a== 0 and b >= 13:
    print("NA")
elif b== 0 and a >= 13:
    print("NA")
elif 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 >= 13 and b <= 12:
    print("YYMM")
elif b >= 13 and a <= 12:
    print("MMYY")
elif a<= 12 and b<= 12:
    print("AMBIGUOUS")
else:
    print("NA")

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

Solution (Python):
s=input()
S=list(s)
m1=0
m2=0
if S[0]=='0':
    if S[1]!='0':
        m1=1
    else:
        m1=0

elif S[0]=='1':
    if S[1]=='0' or S[1]=='1' or S[1]=='2':
        m1=1
    else:
        m1=0
else:
    m1=0

if S[2]=='0':
    if S[3]!='0':
        m2=1
    else:
        m2=0
elif S[2]=='1':
    if S[3]=='0' or S[3]=='1' or S[3]=='2':
        m2=1
    else:
        m2=0
else:
    m2=0

if m1==1 and m2==1:
    print('AMBIGUOUS')

elif m1==1:
    print('MMYY')

elif m2==1:
    print('YYMM')

else:
    print('NA')

Solution (Python):
s = input()
months = ["{:02d}".format(n) for n in range(1,13)]
if (s[:2] in months) & (s[2:] in months):
    print("AMBIGUOUS")
elif s[:2] in months:
    print("MMYY")
elif s[2:] in months:
    print("YYMM")
else:
    print("NA")

Solution (Python):
a = int(input())
s = []
for i in range(4):
  s.append(int(a%10))
  a /= 10
s.reverse()
if (s[0]*10+s[1] >= 13 or s[0]*10+s[1] == 0) and s[2]*10+s[3] >=1 and s[2]*10+s[3]<=12:
  print('YYMM')
elif s[0]*10+s[1] >= 1 and s[0]*10+s[1] <= 12 and (s[2]*10+s[3] >=13 or s[2]*10+s[3] ==0):
  print('MMYY')
elif s[0]*10+s[1] >= 1 and s[0]*10+s[1] <= 12 and s[2]*10+s[3] >= 1 and s[2]*10+s[3] <= 12:
  print('AMBIGUOUS')
else:
  print('NA')

Solution (Python):
s = raw_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:
    print("MMYY")

elif 1<= b <= 12:
    print("YYMM")

else:
    print("NA")

Solution (Python):
S = input()
A = S[:2]
B = S[2:]
if 0<int(A)<13:
  if 0<int(B)<13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0<int(B)<13:
    print("YYMM")
  else:
    print("NA")

Solution (Python):
S = input()

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

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

Solution (Python):

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

def f(x):
        if x >= 13 or x == 0:
                return False
        else:
                return True

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

Solution (Python):
a = list(input())
for i in range(4):
	a[i] = int(a[i])
s = [0,0]
s[0] = a[0]* 10 +a[1]
s[1] = a[2] * 10 + a[3]
def judge(a):
	if 0<a<13:
		return True
	else:
		return False
if judge(s[0]):
	if judge(s[1]):
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if judge(s[1]):
		print("YYMM")
	else:
		print("NA")

Solution (Python):
S = input()
first, second = int(S[:2]), int(S[2:])

if 1 <= first <= 12 and 1 <= second <= 12:
    print("AMBIGUOUS")
elif 1 <= second <= 12:
    print("YYMM")
elif 1 <= first <= 12 and second <= 99:
    print("MMYY")
else:
    print("NA")

Solution (Python):
s=str(input())
aa=int(s[0:2])
bb=int(s[2:])

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

Solution (Python):
s = input()

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

yymm, mmyy = True, True
if s1 > 12 or s1 == 0:
    mmyy = False

if s2 > 12 or s2 == 0:
    yymm = False

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  a=s[:2]
  b=s[2:]
  if a=='00' and int(b)>12:
    print('NA')
  elif int(a)>12 and b=='00':
    print('NA')
  elif a=='00' and b=='00':
    print('NA')
  elif a=='00' and int(b)<=12:
    print('YYMM')
  elif int(a)<=12 and b=='00':
    print('MMYY')
  elif int(a)>12 and int(b)>12:
    print('NA')
  elif int(a)<=12 and int(b)>12:
    print('MMYY')
  elif int(a)>12 and int(b)<=12:
    print('YYMM')
  else:
    print('AMBIGUOUS')

main()

Solution (Python):
text = input()
a = text[:2]
b = text[2:]
m = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
if a in m:
    if b in m:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if b in m:
        print('YYMM')
    else:
        print('NA')

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

    
    
    
    f_canYY = lambda x: '00' <= x and x <= '99'
    f_canMM = lambda x: '01' <= x and x <= '12'

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

    yymm = f_canYY(a) and f_canMM(b)
    mmyy = f_canMM(a) and f_canYY(b)

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

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

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()
ans=[0]*2
if 0<int(S[:2])<13:
    ans[1]=1
if 0<int(S[2:])<13:
    ans[0]=1
if  ans==[1,1]:
    print('AMBIGUOUS')
elif ans==[0,0]:
    print('NA')
elif ans==[1,0]:
    print('YYMM')
else:
    print('MMYY')

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

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

Solution (Python):
S = input()
a,b = int(S[:2]), int(S[2:])
ans = ['NA', 'YYMM', 'MMYY', 'AMBIGUOUS']
idx = 0
if a in range(1,13):
  idx += 2
if b in range(1,13):
  idx += 1
print(ans[idx])

Solution (Python):
S = input()
A = int(S[:2])
B = int(S[2:])
f1 = 1 <= A <= 12
f2 = 1 <= B <= 12
if f1 and f2:
    print('AMBIGUOUS')
elif f1:
    print('MMYY')
elif f2:
    print('YYMM')
else:
    print('NA')

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

a = 1 <= pre and pre <= 12
b = 1 <= post and post <= 12

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

Solution (Python):
S = input()

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

s = [head, tail]
i = [int(si) for si in s]
MM = [True, True]

for j in range(2):
    if i[j] > 12:
        MM[j] = False
    if i[j] < 1:
        MM[j] = False

if MM[0] is True and MM[1] is False:
    print('MMYY')
elif MM[0] is False and MM[1] is True:
    print('YYMM')
elif MM[0] is True and MM[1] is True:
    print('AMBIGUOUS')
else:
    print('NA')

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