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):
input1 = input()

a = input1[0] + input1[1]
b = input1[2] + input1[3]


if a == "01" or a == "02" or a == "03" or a == "04" or a == "05" or a == "06" or a == "07" or a == "08" or a == "09" or a == "10" or a == "11" or a == "12":
    a = "M?"
else:
    a = "?"

if b == "01" or b == "02" or b == "03" or b == "04" or b == "05" or b == "06" or b == "07" or b == "08" or b == "09" or b == "10" or b == "11" or b == "12":
    b = "M?"
else:
    b="?"

if a == "M?" and b == "M?":
    print("AMBIGUOUS")


if a == "M?" and b == "?":
    print("MMYY")

if a == "?" and b == "M?":
    print("YYMM")

if a == "?" and b == "?":
    print("NA")

Solution (Python):

S = str(input())


S1 = int(S[:2])
S2 = int(S[2:])

if S1 == 0 and S2 == 0:
    print("NA")
elif S1 ==0 and 0 < S2 <= 12:
    print("YYMM")
elif S1 == 0 and S2 > 12:
    print("NA")
elif S2 == 0 and S1 > 12:
    print("NA")
elif S2 == 0 and 0 < S1 <= 12:
    print("MMYY")
elif 0 < S1 <= 12 and 0 < S2 <= 12:
    print("AMBIGUOUS")
elif S1 > 12 and 0 < S2 <= 12:
    print("YYMM")
elif 0 < S1 <= 12 and S2 > 12:
    print("MMYY")
elif S1 > 12 and S2 > 12:
    print("NA")

Solution (Python):


S = input()

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

if 1 <= s1 <= 12:
	if 1 <= s2 <= 12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 1 <= s2 <= 12:
		print("YYMM")
	else:
		print("NA")

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


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

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

i = int(s[:2])
j = int(s[2:])

if 1 <= i <= 12:
    if 1 <= j <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= j <= 12:
        print("YYMM")
    else:
        print("NA")

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 and B >= 0:
    print('MMYY')
elif 0 < B <= 12 and A >= 0:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()

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

x = 0 <= A <= 99 and 1 <= B <= 12
y = 1 <= A <= 12 and 0 <= B <= 99

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

Solution (Python):
S = input()
a = int(S[:2])
b = int(S[2:])
ba = 1 <= a <= 12
bb = 1 <= b <= 12
if ba and bb:
    print('AMBIGUOUS')
elif ba and not bb:
    print('MMYY')
elif not ba and bb:
    print('YYMM')
else:
    print('NA')

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

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

Solution (Python):
s = int(input())
L = s//100
R =s%100

if 1 <= L <=12:
    if 1<= R <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<= R <=12:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
import datetime

s = input()
ans = [['NA', 'MMYY'], ['YYMM', 'AMBIGUOUS']]

try:
    datetime.datetime.strptime(s,"%y%m")
    ans1 = 1
except ValueError:
    ans1 = 0

try:
    datetime.datetime.strptime(s,"%m%y")
    ans2 = 1
except ValueError:
    ans2 = 0

print(ans[ans1][ans2])

Solution (Python):
n = list(input())
x = n[0]+n[1]
y = n[2]+n[3]
count = 0
if 12 >= int(y) >= 1:
    count += 1
if 12 >= int(x) >= 1:
    count += 2
if count == 3:
    print("AMBIGUOUS")
elif count == 2:
    print("MMYY")
elif count ==1:
    print("YYMM")
else:
    print("NA")

Solution (Python):
import sys
S = list(input())
S = [S[0]+S[1],S[2]+S[3]]
month = ['01','02','03','04','05','06','07','08','09','10','11','12']



mon = [0,0]
yer = [0,0]

if S[0] in month:
	mon[0] = 1
if S[1] in month:
	mon[1] = 1


if mon[0] == 1 and mon[1] == 1:
	print('AMBIGUOUS')
	sys.exit()
if mon[0] == 1:
	print('MMYY')
	sys.exit()
if mon[1] == 1:
	print('YYMM')
	sys.exit()
else:
	print('NA')
	sys.exit()

Solution (Python):
S = input()

former = int(S[:2])
latter = int(S[2:])

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

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

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

a = x % 100
b = (x - a)//100

fa = False
fb = False

if 0 < a <= 12:
    fa = True
if 0 < b <= 12:
    fb = True
if fa & fb:
    print("AMBIGUOUS")
elif fa:
    print("YYMM")
elif fb:
    print("MMYY")
else:
    print("NA")

Solution (Python):
str_MY = input()
int_f = int(str_MY[:2])
int_b = int(str_MY[2:])
if (12<int_f and 0<int_b<13) or (int_f ==0 and 0<int_b<13):
    print('YYMM')
elif (12<int_b and 0<int_f<13) or (int_b ==0 and 0<int_f<13):
    print('MMYY')
elif 0<int_b<13 and 0<int_f<13:
    print('AMBIGUOUS')
else:
    print('NA')

Solution (Python):
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])
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()
left=int(S[:2])
right=int(S[2:])
mmyy,yymm=False,False
if 12>=left and left>=1:
    mmyy=True
if 12>=right and right>=1:
    yymm=True

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

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

if 1 <= s1 <= 12:
    if 1 <= s2 <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= s2 <= 12:
        print("YYMM")
    else:
        print("NA")

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

Solution (Python):
num = input()

def yymmChecker(num):
    mm = int(num[2:])
    if int(mm) >=1 and int(mm) <= 12:
        return True
    else :
        return False
    
def mmyyChecker(num):
    mm = int(num[:2])
    if int(mm) >=1 and int(mm) <= 12:
        return True
    else :
        return False

yymm_flag = yymmChecker(num)
mmyy_flag = mmyyChecker(num)

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

Solution (Python):
s = str(input())
tmp = 0
flag = False
if 0 < int(s[0]+s[1]) <= 12:
    tmp += 1
    flag = True
if 0 < int(s[2]+s[3]) <= 12:
    tmp += 1

if tmp == 2:
    print('AMBIGUOUS')
elif tmp == 1:
    if flag:
        print('MMYY')
    else:
        print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()
LL,RR = int(S[:2]), int(S[2:])

def v_month(x):
    return  1<=x and x<=12

def v_year(x):
    return 0<=x

m1 = v_month(LL)
y1 = v_year(LL)

m2 = v_month(RR)
y2 = v_year(RR)

if (m1 and y1) and (m2 and y2):
    print("AMBIGUOUS")
elif m1 and y2:
    print("MMYY")
elif y1 and m2:
    print("YYMM")
else:
    print("NA")

Solution (Python):
S=input()
left=S[0:2]
right=S[2:4]
MM=["01","02","03","04","05","06","07","08","09","10","11","12"]

if (left in MM)==False:
   if right in MM:
      print("YYMM")
   else:
      print("NA")

elif left in MM:
   if right in MM:
      print("AMBIGUOUS")
   else:
      print("MMYY")

Solution (Python):
S=int(input())
A,B=S//100,S%100
if A < 13 and B < 13 and A != 0 and B != 0:
  print("AMBIGUOUS")
elif A < 13 and A > 0:
  print("MMYY")
elif B < 13 and B > 0:
  print("YYMM")
else:
  print("NA")

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

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

Solution (Python):
def check(a, b):
    if 1<= a <= 12 and 1 <= b <= 12:
        return "AMBIGUOUS"
    elif 1 <= a <= 12 and (b <= 0 or 13 <= b):
        return "MMYY"
    elif (a <= 0 or 13 <= a) and 1 <= b <= 12:
        return "YYMM"
    else:
        return "NA"

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

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 and (12<B<99 or B==0):
  print('MMYY')
elif 0<B<13 and (12<A<99 or A==0):
  print('YYMM')
else:
  print('NA')

Solution (Python):
s = input()
def solve(s):
    m = int(s[:2])
    n = int(s[2:])
    u=0
    if 1<=n<=12:
        u = 1
    v=0
    if 1<=m<=12:
        v=1
    if v==1 and u==1:
        return 'AMBIGUOUS'
    if v==1 and u==0:
        return 'MMYY'
    if v==0 and u==1:
        return 'YYMM'
    return 'NA'    
print(solve(s))

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

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

Solution (Python):
S = input()

a = S[0]+S[1]
b = S[2]+S[3]

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

if a in month and b in month:
    ans = 'AMBIGUOUS'
elif a in month:
    ans = 'MMYY'
elif b in month:
    ans = 'YYMM'
else:
    ans = 'NA'

print(ans)

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

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

if 1 <= l[0] <= 12:
    if 1 <= l[1] <= 12:
        print("AMBIGUOUS")
    elif l[1] == 0 or 13 <= l[1]:
        print("MMYY")
    else:
        print("NA")
elif l[0] == 0 or 13 <= l[0]:
    if 1 <= l[1] <= 12:
        print("YYMM")
    else:
        print("NA")
else:
    print("NA")

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

if (S1 >= 0) and (S2 < 13) and (S2 > 0):
    flag += 1
if (S1 < 13) and (S2 >= 0) and (S1 > 0):
    flag += 10

if flag == 11:
    print("AMBIGUOUS")
elif flag == 1:
    print("YYMM")
elif flag == 10:
    print("MMYY")
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 0 < S1 <= 12:
    print('MMYY')
elif 0 < S2 <= 12:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()
L = ["NA", "MMYY", "YYMM", "AMBIGUOUS"]
print(L[(0 < int(S[0:2]) <= 12) + 2 * (0 < int(S[2:4]) <= 12)])

Solution (Python):
S = input()

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

print(ans)

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

YYMM = 1 <= back  <= 12
MMYY = 1 <= front <= 12

if YYMM and MMYY:
  print("AMBIGUOUS")
  exit()

if not YYMM and not MMYY:
  print("NA")
  exit()

if YYMM:
  print("YYMM")

if MMYY:
  print("MMYY")

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


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

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

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

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

Solution (Python):
S=input()
A1=int(S[0:2])
A2=int(S[2:4])

if 12>=A2>=1:
    if 12>=A1>=1:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if 12>=A1>=1:
        print("MMYY")
    else:
        print("NA")

Solution (Python):
s = input()

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

if (a==0 or 12<a<100) and (b==0 or 12<b<100):
    print('NA')

elif (a==0 or 12<a<100) and 1<=b<=12:
    print('YYMM')

elif 1<=a<=12 and (b==0 or 12<b<100):
    print('MMYY')

else:
    print('AMBIGUOUS')

Solution (Python):
n=input()
a=int(n[0]+n[1])
b=int(n[2]+n[3])
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<13 and a>0 and b<13 and b>0:
    print('AMBIGUOUS')
elif a<13 and a>0:
    print('MMYY')
elif b<13 and b>0:
    print('YYMM')
else:
    print('NA')

Solution (Python):


s = list(input())

a = s[0]+s[1]
b = s[2]+s[3]

a_canBeM = False
b_canBeM = False
canBeY = True

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

if a in M:
    a_canBeM = True
if b in M:
    b_canBeM = True

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

Solution (Python):
S = input()

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

ans = "NA"
if 1 <= head <= 12:
    if 1 <= tail <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
elif 1 <= tail <= 12:
    ans = "YYMM"

print(ans)

Solution (Python):
s = input()

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

ans = 0

if int(a) <= 12 and int(a) >= 1:
    ans += 2

if int(b) <= 12 and int(b) >= 1:
  ans += 3
  
if ans == 0:
  print("NA")
elif ans == 2:
  print("MMYY")
elif ans == 3:
  print("YYMM")
elif ans == 5:
  print("AMBIGUOUS")

Solution (Python):
A, = [s.split() for s in open(0)][0]

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

yymm = 0
mmyy = 0

if a >= 1 and a <= 12:
    mmyy += 1

if b >= 1 and b <= 12:
    yymm += 1
    
if mmyy and yymm:
    print("AMBIGUOUS")
elif mmyy and not yymm:
    print("MMYY")
elif not mmyy and yymm:
    print("YYMM")
else:
    print("NA")

Solution (Python):
import sys
input = sys.stdin.readline
S = input()
a = int(S[:2])
b = int(S[2:])
if (0<=a<=99 and 1<=b<=12) or (1<=a<=12 and 0<=b<=99):
    if 1<=a<=12 and 1<=b<=12:
        print ("AMBIGUOUS")
    elif 0<=a<=99 and 1<=b<=12:
        print("YYMM")
    else:
        print("MMYY")
else:
    print("NA")

Solution (Python):
s = input()

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

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

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

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

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

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

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


if first >= 1 and first <= 12:
  if second >= 1 and second <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if second >= 1 and second <= 12:
    print('YYMM')
  else:
    print('NA')

Solution (Python):
s = input()
m1 = '00'<s[:2]<'13'
m2 = '00'<s[2:]<'13'
if m1 and m2:
    print('AMBIGUOUS')
elif not m1 and m2:
    print('YYMM')
elif m1 and not m2:
    print('MMYY')
else:
    print('NA')

Solution (Python):
s = input()

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

if 1 <= s1 <= 12:
    if 1 <= s2 <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if 1 <= s2 <= 12:
        ans = "YYMM"
    else:
        ans = "NA"
    
print(ans)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Solution (Python):
s = input()
aa = int(s[:2])
bb = int(s[2:])
aa_mm = False
bb_mm = False
if 1 <= aa <= 12:
    aa_mm = True
if 1 <= bb <= 12:
    bb_mm = True
if aa_mm and bb_mm:
    print("AMBIGUOUS")
elif bb_mm:
    print("YYMM")
elif aa_mm:
    print("MMYY")
else:
    print("NA")

Solution (Python):
N = int(input())
y = [0,1,2,3,4,5,6,7,8,9]
one = [1]
zero = [0]
p = [1,2,3,4,5,6,7,8,9]
q = [0,1,2]
a=N//1000
b=(N - (a * 1000))//100 
c=(N- (a*1000)-(b * 100))// 10
d=(N - (a*1000)-(b*100)-(c*10))

if ((a in one) and (b in q)or(a in zero) and (b in p))and((c in one) and (d in q)or(c in zero)and(d in p)):
  print('AMBIGUOUS')
elif (a in y )and(b in y)and((c in one) and (d in q) or (c in zero) and(d in p)):
  print('YYMM')
elif ((a in one )and(b in q))or((a in zero)and(b in p))and(c in y) and (d in y):
  print('MMYY')
else:
  print('NA')

Solution (Python):
S = str(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):
S = input()

S_a = int(S[:2])
S_b = int(S[2:])

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

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

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

Solution (Python):


S = input()

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

S1_flg = False
S2_flg = False
if "01" <= S1 and S1 <= "12":
    S1_flg = True
if "01" <= S2 and S2 <= "12":
    S2_flg = True
if   S1_flg == False and S2_flg == False:
    print("NA")
elif S1_flg == False and S2_flg == True:
    print("YYMM")
elif S1_flg == True  and S2_flg == False:
    print("MMYY")
else:
    print("AMBIGUOUS")

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

s1=s//100
s2=s%100

ok1=ok2=False
if s1>0 and s1<13:
	ok1=True

if s2>0 and s2<13:
	ok2=True

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

Solution (Python):
s = input()

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

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

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

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

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

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

Solution (Python):

def P(s):
    print(s)
    exit(0)

s = input()
l = int(s[:2])
r = int(s[2:])
if 1 <= l and l <= 12:
    if 1 <= r and r <= 12:
        P("AMBIGUOUS")
    else:
        P("MMYY")
else:
    if 1 <= r and r <= 12:
        P("YYMM")
    else:
        P("NA")

Solution (Python):
S=input()

tmp1=int(S[0:2])
tmp2=int(S[2:4])

if(1 <= tmp1 <= 12 and 1 <= tmp2 <= 12):
    print("AMBIGUOUS")
elif((1 <= tmp1 <= 12)==False and  1 <=tmp2 <= 12):
    print("YYMM")
elif((1 <= tmp2 <= 12)==False and  1 <=tmp1 <= 12):
    print("MMYY")
else:
    print("NA")

Solution (Python):
s = input()

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

aa= ''
bb= ''

if (12>= a >0):
    aa = 'M'

if (12>= b >0):
    bb = 'M'

if (aa == 'M' and bb == 'M'):
    print('AMBIGUOUS')

if (aa == 'M' and bb != 'M'):
    print('MMYY')

if (aa != 'M' and bb == 'M'):
    print('YYMM')

if (aa != 'M' and bb != 'M'):
    print('NA')

Solution (Python):

s=input()

month = [str(i).zfill(2) for i in range(1,13)]

if s[2:] in month:
    if s[:2] in month:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if s[:2] in month:
        print("MMYY")
    else:
        print("NA")

Solution (Python):
s=input()
f1=True
f2=True
if int(s[:2])==0 or int(s[:2])>12:
    f1=False
if int(s[2:])==0 or int(s[2:])>12:
    f2=False
if f1 and f2:
    print("AMBIGUOUS")
elif f1:
    print("MMYY")
elif f2:
    print("YYMM")
else:
    print("NA")

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

Solution (Python):

def isMonth(value):
  return (value >= 1) and (value <= 12)


s = input()
first = int(s[:2])
last = int(s[2:])

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

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

Solution (Python):
s = list(input())
s1 = int("".join(s[0:2]))
s2 = int("".join(s[2:4]))
result = ""

if (1<=s1<=12) and (1<=s2<=12):
    result = "AMBIGUOUS"
elif (0<=s1<=99) and (1<=s2<=12):
    result = "YYMM"
elif (1<=s1<=12) and (0<=s2<=99):
    result = "MMYY"
else:
    result = "NA"
print(result)

Solution (Python):
s = list(str(input()))
f = [s[0],s[1]]
d = int("".join(f))
f = [s[2], s[3]]
e = int("".join(f))
if (d > 12 or d == 0) and (12 >= e > 0):
    print("YYMM")
elif (12 >= d > 0) and (e > 12 or e == 0):
    print("MMYY")
elif (12>=d>0)and(12>=e>0):
    print("AMBIGUOUS")
else:
    print("NA")

Solution (Python):

S = input()
first = int(S[0]+S[1])
second = int(S[2]+S[3])

if first > 12:
    if second > 12:
        print("NA")
    elif second > 0:
        print("YYMM")
    else: 
        print("NA")
elif first > 0:
    if second > 12:
        print("MMYY")
    elif second > 0:
        print("AMBIGUOUS")
    else: 
        print("MMYY")
else: 
    if second > 12:
        print("NA")
    elif second > 0:
        print("YYMM")
    else: 
        print("NA")

Solution (Python):
S = [x for x in input()]
a = int(S[0]+""+S[1])
b = int(S[2]+""+S[3])

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

Solution (Python):
s = input()
yy = int(s[:len(s)//2])
mm = int(s[len(s)//2:])

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

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

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

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

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

a = int(s[:2])
b = int(s[2:])
month = [int(i) for i in range(1,13)]

if a in month and b in month:
    print('AMBIGUOUS')

elif a in month:
    print('MMYY')

elif b in month:
    print('YYMM')

else:
    print('NA')

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

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

Solution (Python):
S = input()
YYMM = MMYY = False
A = int(S[:2:])
B = int(S[2::])

if 1 <= B <= 12:
    YYMM = True

if 1 <= A <= 12:
    MMYY = True

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

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

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

a = True
b = True

if int(S[0]) > 1 or (int(S[0]) == 1 and int(S[1]) > 2) or (int(S[0]) == 0 and int(S[1]) == 0):
    a = False
if int(S[2]) > 1 or (int(S[2]) == 1 and int(S[3]) > 2) or (int(S[2]) == 0 and int(S[3]) == 0):
    b = False

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

Solution (Python):
a = input()
a1 = int(a[:2])
a2 = int(a[2:])

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

Solution (Python):
s = input()
nums = [int(s[0]+s[1]), int(s[2]+s[3])]
if nums[0] >= 1 and nums[0] <= 12:
  month = True
else:
  month = False
if nums[1] >= 1 and nums[1] <= 12:
  if month:
    print("AMBIGUOUS")
  else:
    print("YYMM")
else:
  if month:
    print("MMYY")
  else:
    print("NA")

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

Solution (Python):
s = input()

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

is_yymm = False
is_mmyy = False

if 1 <= l and l <= 12 and 0 <= r and r <= 99:
  is_mmyy = True

if 1 <= r and r <= 12 and 0 <= l and l <= 99:
  is_yymm = True

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

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

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

ff = int(S[0])*10 + int(S[1])
bb = int(S[2])*10 + int(S[3])

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

Solution (Python):
s = input()
a, b = s[:2], s[2:]
def isMonth(string):
  if int(string) >= 1 and int(string) <= 12:
    return True
  else:
    return False
if isMonth(a) and isMonth(b):
  print("AMBIGUOUS")
elif isMonth(a) and not(isMonth(b)):
  print("MMYY")
elif not(isMonth(a)) and isMonth(b):
  print("YYMM")
else:
  print("NA")

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

ue = 10*s[0] + s[1]
shita = 10*s[2] + s[3]

if 0 < ue < 13:
  if 0 < shita < 13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0 < shita < 13:
    print("YYMM")
  else:
    print("NA")

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

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

UN2 = 10 * S[-2] + S[-1]
UP2 = 10 * S[0] + S[1]

if ((1000*UP2)+UN2) == 0 or ((UP2 >= 13) and (UN2 >= 13)) or ((UP2 >= 13) and UN2 == 0) or ((UP2 == 0) and UN2 >= 13) :
    print('NA')
elif (1 <= UP2 <= 12) and (1 <= UN2 <= 12) :
    print('AMBIGUOUS')
elif UP2 == 0 or UP2 >= 13 :
    print('YYMM')
else :
    print('MMYY')

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

Solution (Python):
a,b,c,d = str(input())

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

Solution (Python):
S = input()
head, tail = int(S[:2]), int(S[2:])
if 0 < head < 13:
    if 0 < tail < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < tail < 13:
        print('YYMM')
    else:
        print('NA')

Solution (Python):

S = input()

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

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

Solution (Python):
S = input()

pre = int(S[:2])
aft = int(S[2:])

if 0 < pre < 13:
    
    print('AMBIGUOUS') if 0 < aft < 13 else print('MMYY')
else:
    
    print('YYMM') if 0 < aft < 13 else print('NA')

Solution (Python):
s=int(input())
x=s%100
y=s//100
print(("AMBIGUOUS" if 0<x<13 else "MMYY") if 0<y<13 else "YYMM" if 0<x<13 else "NA")