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

mae = str(S[:2])
ato = str(S[2:])

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

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

Solution (Python):
s = input()

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

if (l > 0 and l < 13) and (r > 0 and r < 13):
    ret = 'AMBIGUOUS'
elif (l > 0 and l < 13) and (r == 0 or r >= 13):
    ret = 'MMYY'
elif (l == 0 or l >= 13) and (r > 0 and r < 13):
    ret = 'YYMM'
else:
    ret = 'NA'

print(ret)

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

Solution (Python):
s = input()
YYMM, MMYY, ova = False, False, False
if(1 <= int(s[:2]) <= 12):
    MMYY = True
if(1 <= int(s[2:]) <= 12):
    YYMM = True

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

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

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):
N=list(input())
MM=["01","02","03","04","05","06","07","08","09","10","11","12"]
YY=["00","01","02","03","04","05","06","07","08","09"]

for i in range(10,100):

        YY.append(str(i))

if str(N[0])+str(N[1]) in YY and str(N[0])+str(N[1]) in MM and str(N[2])+str(N[3]) in YY and str(N[2])+str(N[3]) in MM:
    print("AMBIGUOUS")

elif str(N[0])+str(N[1]) in MM and str(N[2])+str(N[3]) in YY:
    print("MMYY")

elif str(N[0])+str(N[1]) in YY and str(N[2])+str(N[3]) in MM:
    print("YYMM")

else:
    print("NA")

Solution (Python):
S = input()
a = 0
b = 0
if (S[0] == '0' and S[1] != '0') or (S[0] == '1' and (S[1] == '0' or S[1] == '1' or S[1] == '2')):
  a = 1
if (S[2] == '0' and S[3] != '0') or (S[2] == '1' and (S[3] == '0' or S[3] == '1' or S[3] == '2')):
  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()
f=int(s[:2])
g=int(s[2:])
if 0<f<13 and 0<g<13:
  print('AMBIGUOUS')
elif 0<f<13:
  print('MMYY')
elif 0<g<13:
  print('YYMM')
else:
  print('NA')

Solution (Python):

s = list(input())

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

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    s = input().rstrip()
    a = s[:2]
    b = s[2:]
    a = int(a)
    b = int(b)
    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')

if __name__ == '__main__':
    main()

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

def month(n):
  if 1 <= n <= 12:
    return True
  else:
    return False

if month(U) == True and month(L) == True:
  print("AMBIGUOUS")
elif month(U) == True and month(L) == False:
  print("MMYY")
elif month(U) == False and month(L) == True:
  print("YYMM")
else:
  print("NA")

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

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

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

S1 = int(S[0]+S[1])
S2 = int(S[2]+S[3])

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

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

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

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

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

Solution (Python):
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
m = range(1,13)
if s1 in m and s2 in m:
    print('AMBIGUOUS')
elif s1 in m:
    print('MMYY')
elif s2 in m:
    print('YYMM')
else:
    print('NA')

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

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

if 0<form<=12:
  if 0<latt<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
elif 0<latt<=12:
  print("YYMM")
else:
  print("NA")

Solution (Python):
S = input()

L = int(S[:2])
R = int(S[2:])

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

Solution (Python):


s = str(input()) 

def check(n):
    if n > 0 and n <= 12:
        return True
    else:
        return False

mae = check(int(s[0:2]))
ato = check(int(s[2:4]))

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

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

if 13<=S//100<=99 or S//100==0:
  if 1<=S%100<=12:
    print("YYMM")
  else:
    print("NA")
else:
  if 13<=S%100<=99 or S%100==0:
    print("MMYY")
  else:
    print("AMBIGUOUS")

Solution (Python):

S = input()
head, tail = S[:2], S[2:]
if 1 <= int(head) <= 12 and 1 <= int(tail) <= 12:
    print('AMBIGUOUS ')
elif 1 <= int(head) <= 12 and not (1 <= int(tail) <= 12):
    print('MMYY')
elif not (1 <= int(head) <= 12) and 1 <= int(tail) <= 12:
    print('YYMM')
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()
aa = int(s[0]+s[1])
bb = int(s[2]+s[3])
if aa>=13 or aa==0:
    print('YYMM') if 0<bb<13 else print('NA')
else:
    print('AMBIGUOUS') if 0<bb<13 else print('MMYY')

Solution (Python):
s = input()

aa = int(s[0]+s[1])
bb = int(s[2]+s[3])
if aa>=13 or aa==0:
    if 0<bb<13:
        print('YYMM')
    else:
        print('NA')
else:
    if 0<bb<13:
        print('AMBIGUOUS')
    else:
        print('MMYY')

Solution (Python):
S = input()
A = int(S[0]+S[1])
B = int(S[2]+S[3])
if 0 < A <= 12:
    if 0 < B <= 12:
        print('AMBIGUOUS')

    else:
        print('MMYY')

elif A > 12 or A == 0:
    if 0 < B <= 12:
        print('YYMM')

    else:
        print('NA')

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

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

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  S=input()
  A=int(S[:2])
  B=int(S[2:])
  if 1<=A<=12:
    if 1<=B<=12:
      print("AMBIGUOUS")
    else:
      print("MMYY")
  else:
    if 1<=B<=12:
      print("YYMM")
    else:
      print("NA")
      
if __name__ == '__main__':
  main()

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

if 1 <= head and head <= 12:
    if 1 <= back and back <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= back and back <= 12:
        print('YYMM')
    else:
        print('NA')

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

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

Solution (Python):
Ss = input().rstrip()

isYYMM = '01' <= Ss[2:] <= '12'
isMMYY = '01' <= Ss[:2] <= '12'

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

Solution (Python):
s = int(input())
s_1 = s // 100 
s_2 = s % 100  

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

Solution (Python):
S = int(input())
s1 = S//100
s2 = S%100

if s1 > 0 and s1 <=12:
  flag1 = True
else:
  flag1 = False
if s2 > 0 and s2 <=12:
  flag2 = True
else:
  flag2 = False
  
if flag1 and flag2:
  print("AMBIGUOUS")
if not flag1 and flag2:
  print("YYMM")
if flag1 and not flag2:
  print("MMYY")
if not flag1 and not flag2:
  print("NA")

Solution (Python):
S = input()


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

Solution (Python):
S = input()
a = int(S[:2])
b = int(S[2:])
if a >= 1 and a <= 12 and b >= 1 and b <= 12:
    print('AMBIGUOUS')

elif a >= 1 and a <= 12:
    print('MMYY')

elif b>= 1 and b <= 12:
    print('YYMM')

else:
    print('NA')

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

Solution (Python):
s = input()
yymm = False
mmyy = False

if 1 <= int(s[:2]) <= 12:
    mmyy = True
if 1 <= int(s[2:]) <= 12:
    yymm = True

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

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

Solution (Python):
data=input()
n=int(data[:2])
m=int(data[2:])
if 1<=n<=12:
    if 1<=m<=12:
        print("ambiguous".upper())
        exit()
    else:
        print("MMYY")
        exit()
if 1<=m<13:
    print("YYMM")
    exit()
print("NA")

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

Ans=[int(S[0]+S[1]),int(S[2]+S[3])]

if 0<Ans[0]<13 and 0<Ans[1]<13:
    print("AMBIGUOUS")
elif 0<Ans[0]<13:
    print("MMYY")
elif 0<Ans[1]<13:
    print("YYMM")
else:
    print("NA")

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

S_list = [int(S[:2]), int(S[2:])]


if 1 <= S_list[1] and S_list[1] <= 12 and 1 <= S_list[0] and S_list[0] <= 12:
    print('AMBIGUOUS')
elif 1 <= S_list[1] and S_list[1] <= 12:
    print('YYMM')
elif  1 <= S_list[0] and S_list[0] <= 12:
    print('MMYY')
else:
    print('NA')

Solution (Python):
import collections, math, bisect

local = False
if local:
    file = open("input.txt", "r")
    import time

def inp():
    if local:
        return file.readline().rstrip()
    else:
        return input().rstrip()

def ints():
    return [int(_) for _ in inp().split()]


if local:
    start=time.time()

S = inp()

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

YYMMvalid = S[2::] in months
MMYYvalid = S[0:2] in months

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

if local:
    fin = (time.time()-start)*1000
    print("{:.2f}".format(fin) + "ms")

Solution (Python):






s = str(input())
s_former = int(s[:2])
s_latter = int(s[2:])

if 1 <= s_former <= 12:
    if 1 <= s_latter <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if 1 <= s_latter <= 12:
        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 1<=int(s[0:2])<=12:
    print("MMYY")
elif 1<=int(s[2:4])<=12:
    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 1<=int(s[0:2])<=12:
    print("MMYY")
elif 1<=int(s[2:4])<=12:
    print("YYMM")
else:
    print("NA")

Solution (Python):
a,b,c,d=input()
ym,my=int(a+b),int(c+d)
if 0<ym<13 and 0<my<13:
    print('AMBIGUOUS')
elif 0<ym<13:
    print('MMYY')
elif 0<my<13:
    print('YYMM')
else:
    print('NA')

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

F = int(S[0]+S[1])
L = int(S[2]+S[3])

if (L == 0 and F == 0) or (F > 12 and L > 12) or (F == 0 and L > 12) or (L == 0 and F > 12):
  print('NA')

elif F <= 12 and (L > 12 or L == 0):
  print('MMYY')
  
elif L <= 12 and (F > 12 or F == 0):
  print('YYMM')
  
 
else:
  print('AMBIGUOUS')

Solution (Python):
def solve_128b(a, b):
    if 1 <= a & a <= 12:
        if 1 <= b & b <= 12:
            return "AMBIGUOUS"
        else:
            return "MMYY"
    else:
        if 1 <= b & b <= 12:
            return "YYMM"
        else:
            return "NA"

s = int(input())
s2 = int(s / 100)
s1 = s % 100
print(solve_128b(s2, s1))

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("YYMM")
elif 1 <= int(S[:2]) <= 12:
    print("MMYY")
else:
    print("NA")

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

Solution (Python):
S = input()
months = [
    '01', '02', '03',
    '04', '05', '06',
    '07', '08', '09',
    '10', '11', '12']
if S[:2] in months and 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):
S=input()
F=int(S[:2])
L=int(S[2:])

if 0<F<=12:
    if 0<L<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0<L<=12:
    print('YYMM')
else:
    print('NA')

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

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

front = S // 100
back = S % 100

if 1 <= front <= 12 :
    if  1 <= back <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= back <= 12:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
S = input()

L = int(S[:2])
R = int(S[2:])

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

Solution (Python):
num = int(input())
p1 = num//100
p2 = num%100

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

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

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

if f>=1 and f<=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 = input()
a = list(map(str, range(1, 10)))
b = list(map(str, range(0, 3)))
mm = 0
ba = 0
for i in [0, 2]:
    if s[i] == "0" and s[i+1] in a:
        mm += 1
        ba = i
    elif s[i] == "1" and s[i+1] in b:
        mm += 1
        ba = i
if mm == 0:
    print("NA")
elif mm == 1 and ba == 0:
    print("MMYY")
elif mm == 1 and ba == 2:
    print("YYMM")
elif mm == 2:
    print("AMBIGUOUS")

Solution (Python):
s = input()
a = int(s[:2])
b = int(s[2:])
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):
form = input().strip()
m_limit = ["{:0>2}".format(i) for i in range(1, 13)]

f2d, l2d = form[:2], form[2:]
if f2d in m_limit and l2d in m_limit:
    print("AMBIGUOUS")
elif f2d in m_limit:
    print("MMYY")
elif l2d in m_limit:
    print("YYMM")
else:
    print("NA")

Solution (Python):
a=int(input())
x=a//100
y=a%100
c=False
d=False
if 1<= x<=12:
    c=True
if 1<= y<=12:
    d=True
if c==True and d==True:
    print("AMBIGUOUS")
if c==True and d==False:
    print("MMYY")
if c==False and d==True:
    print("YYMM")
if c==False and d==False:
    print("NA")

Solution (Python):
S = input()
S_a = int(S[0] + S[1])
S_b = int(S[2] + S[3])
if((S_a >= 1 and S_a <= 12) and (S_b < 1 or S_b > 12)):
  print('MMYY')
elif((S_a < 1 or S_a > 12) and (S_b >= 1 and S_b <= 12)):
  print('YYMM')
elif((S_a >= 1 and S_a <= 12) and (S_b >= 1 and S_b <= 12)):
  print('AMBIGUOUS')
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=int(input())
n1=s//100
n2=s%100
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):
S = input()
f, l = S[:2], S[2:]

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

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

Solution (Python):
s = input()
am = s[0]+s[1]
pm = s[2]+s[3]
p = ["01","02","03","04","05","06","07","08","09","10","11","12"]
if am in p and pm in p:
    print("AMBIGUOUS")
elif am in p and pm not in p:
    print("MMYY")
elif am not in p and pm in p:
    print("YYMM")
elif am not in p and pm not in p:
    print("NA")

Solution (Python):
S = input()

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

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

Solution (Python):
s = input()

forward = s[:2]
backward = s[2:]
def check(s):
    if 0<int(s)<=12:
        return True
    else:
        return False

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

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

Solution (Python):
S=input();A=S[:2];B=S[2:];x=1*(sorted([A,'01','12'])[1]==A);y=2*(sorted([B,'01','12'])[1]==B);print(['NA','MMYY','YYMM','AMBIGUOUS'][x+y])

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

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

Solution (Python):

s = input()
a = list(map(str, range(1, 10)))
b = list(map(str, range(0, 3)))
mm = 0
ba = 0
for i in [0, 2]:
    if s[i] == "0" and s[i+1] in a:
        mm += 1
        ba = i
    elif s[i] == "1" and s[i+1] in b:
        mm += 1
        ba = i
if mm == 0:
    print("NA")
elif mm == 1 and ba == 0:
    print("MMYY")
elif mm == 1 and ba == 2:
    print("YYMM")
elif mm == 2:
    print("AMBIGUOUS")

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

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = list(sr())
head = int(''.join(S[:2]))
tail = int(''.join(S[2:]))
bl_head = (1 <= head <= 12)
bl_tail = (1 <= tail <= 12)
if bl_head and bl_tail:
    answer = "AMBIGUOUS"
elif bl_head:
    answer = "MMYY"
elif bl_tail:
    answer = "YYMM"
else:
    answer = "NA"

print(answer)

Solution (Python):
S = input()
s1,s2 = map(int, [S[:2],S[2:]])
if all(map(lambda x: x in range(1,13), [s1,s2])): ans = "AMBIGUOUS"
elif s1 in range(1,13): ans = "MMYY"
elif s2 in range(1,13): ans = "YYMM"
else: ans = "NA"
print(ans)

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

if 0 <r <13:
    if 0 <l <13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0 <l <13:
    if 0 <r <13:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()

is_YY = lambda string: True
is_MM = lambda string: 1 <= int(string) <= 12

is_YYMM = lambda string: is_YY(string[0:2]) and is_MM(string[2:4])
is_MMYY = lambda string: is_MM(string[0:2]) and is_YY(string[2:4])

answer = ''
if is_YYMM(S) and not is_MMYY(S):
    answer = 'YYMM'
elif not is_YYMM(S) and is_MMYY(S):
    answer = 'MMYY'
elif is_YYMM(S) or is_MMYY(S):
    answer = 'AMBIGUOUS'
else:
    answer = 'NA'

print(answer)

Solution (Python):
s = input()
be = int(s[0:2])
af = int(s[2:4]) 
if 0 < be < 13:
  if 1 <= af <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
elif 0 < af < 13:
  if 1 <= be <= 12:
    print('AMBIGUOUS')
  else:
    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):
input_s = input()
head_num = int(input_s[:2])
bottom_num = int(input_s[2:])
yymm_flag = 0
mmyy_flag = 0

if bottom_num <= 12 and bottom_num != 0:
    yymm_flag += 1


if head_num <= 12 and head_num != 0:
    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):
S = input()
l, r = map(int, [S[:-2], S[2:]])

if 0 < l < 13:
    if 0 < r < 13:
        print('AMBIGUOUS')
        exit()
    else:
        print('MMYY')
else:
    if 0 < r < 13:
        print('YYMM')
    else:
        print('NA')

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

Solution (Python):
n = input()
a = int(n[:2])
b = int(n[2:])
x = 0 < a <= 12
y = 0 < b <= 12
if x and y :
    print('AMBIGUOUS')
elif not x and y:
    print('YYMM')
elif x and not y:
    print('MMYY')
else:
    print('NA')

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

def may_month(s):
  return 1<=s<=12


if may_month(s1) and may_month(s2):
  print("AMBIGUOUS")
  

elif not (may_month(s1) or may_month(s2)):
  print("NA")


elif may_month(s1):
  print("MMYY")
  

elif may_month(s2):
  print("YYMM")

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
s=input()
fr=s[0:2]
ba=s[2:4]
if 1<=int(fr)<=12 and 1<=int(ba)<=12:
    ans="AMBIGUOUS"
elif 1<=int(fr)<=12 and (int(ba)<1 or int(ba)>12):
    ans="MMYY"
elif 1<=int(ba)<=12 and (int(fr)<1 or int(fr)>12):
    ans="YYMM"
elif (int(ba)<1 or int(ba)>12) and (int(ba)<1 or int(ba)>12):
    ans="NA"
print(ans)

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

Solution (Python):
a = input()
frm = int(a[:2])
lat = int(a[2:])


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

Solution (Python):
import sys







from operator import attrgetter, itemgetter






readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    first = int(s[0:2])
    second = int(s[2:4])

    mm = [False] * 2

    if 1 <= first <= 12:
        mm[0] = True

    if 1 <= second <= 12:
        mm[1] = True

    if mm[0] and mm[1]:
        print("AMBIGUOUS")
    elif mm[0]:
        print("MMYY")
    elif mm[1]:
        print("YYMM")
    else:
        print("NA")


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
n = int(input())
l = n // 100
r = n % 100
yymm = 1 <= r <= 12
mmyy = 1 <= l <= 12
if yymm:
    print('AMBIGUOUS' if mmyy else 'YYMM')
else:
    print('MMYY' if mmyy else 'NA')

Solution (Python):
S = input()
a, b = int(S[:2]), int(S[2:])
c = set(list(range(1, 12 + 1)))

if a in c and b in c:
    print('AMBIGUOUS')
    exit()
if a in c:
    print('MMYY')
    exit()
if b in c:
    print('YYMM')
    exit()
print('NA')
exit()

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = input()
    isMM = lambda s: int(s) > 0 and int(s) <= 12
    isOnlyYY = lambda s: int(s)>12 or int(s) == 0
    if   isMM(S[:2]) and isOnlyYY(S[2:]): print('MMYY')
    elif isOnlyYY(S[:2]) and isMM(S[2:]): print('YYMM')
    elif isMM(S[:2]) and isMM(S[2:]): print('AMBIGUOUS')
    else: print('NA')

if __name__ == '__main__':
    main()