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):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

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






if __name__ == "__main__":
    main()

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

Solution (Python):
n=input()

n1,n2=int(n[:2]),int(n[2:])


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

Solution (Python):
n=input()

n1,n2=int(n[:2]),int(n[2:])
if (n1>12 and n2>12) or (n1==0 and n2==0):
    print("NA")
elif (n1!=0 and n1<=12) and (n2!=0 and n2<=12):
    print("AMBIGUOUS")
elif n1!=0 and n1<=12:
    print("MMYY")
elif n2!=0 and n2<=12:
    print("YYMM")
else:
    print("NA")

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

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

Solution (Python):
S =int(input())
a = S // 100
b = S % 100
if 0 < a < 13 :
  if 0 < b < 13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0 < b < 13:
    print("YYMM")
  else:
    print("NA")

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

Solution (Python):
s=input()
ans=[0]*2
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12:
    ans[0]=1
if 1<=b<=12:
    ans[1]=1

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

Solution (Python):
s = input()
first = 0 < int(s[:2]) < 13
second = 0 < int(s[2:]) < 13

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

Solution (Python):
s=input()
ans=[0]*2
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12:
    ans[0]=1
if 1<=b<=12:
    ans[1]=1

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

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

Solution (Python):
s = input()
ans = 0
for i in range(0,3,2):
  if s[i] == "0" and s[i+1] == "0":
    continue
  elif s[i] == "0":
    ans += i+1
  elif (s[i] == "1" and s[i+1] == "0") or (s[i] == "1" and s[i+1] == "1") or (s[i] == "1" and s[i+1] == "2"):
    ans += i+1
if ans == 1:
  print("MMYY")
elif ans == 3:
  print("YYMM")
elif ans == 4:
  print("AMBIGUOUS")
else:
  print("NA")

Solution (Python):
import sys
sys.setrecursionlimit(10**6)




s = input()







l = [i for i in range(1,13)]
l = [str(i) if len(str(i))==2 else '0'+str(i) for i in l]

if s[:2] not in l and s[2:] not in l:
    print('NA')
elif s[:2] not in l and s[2:] in l:
    print('YYMM')
elif s[:2] in l and s[2:] not in l:
    print('MMYY')
else:
    print('AMBIGUOUS')

Solution (Python):
date=input()
if 1<=int(date[:2])<=12:
    if 1 <= int(date[2:]) <= 12:
        print("AMBIGUOUS")
        exit(0)
    else:
        print("MMYY")
        exit(0)
if int(date[2:])==0 or 13 <= int(date[2:]):
    print("NA")
    exit(0)
print("YYMM")

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

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

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

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

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

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

s1m = False
s1y = False
s2m = False
s2y = False
if s1 <= 12 and s1 >= 1:
  s1y = True
  s1m = True
elif s1 > 12 or s1 == 0:
  s1y = True
  
if s2 <= 12 and s2 >= 1:
  s2y = True
  s2m = True
elif s2 > 12  or s2 == 0:
  s2y = True

if s1y and s2y and s1m and s2m:
  print("AMBIGUOUS")
elif s1y and s2m :
  print("YYMM")
elif s2y and s1m :
  print("MMYY")
else :
  print("NA")

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

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

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

Solution (Python):
S = input()

first_two = int(S[:2])
last_two = int(S[-2:])

if first_two == 0 or first_two > 12:
    if last_two == 0:
        print('NA')
    elif last_two <= 12:
        print('YYMM')
    else:
        print('NA')
elif first_two <= 12:
    if last_two == 0:
        print('MMYY')
    elif last_two <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    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')


if __name__ == '__main__':
    main()

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

Solution (Python):
S = int(input())
a = S % 100
b = (S- (S % 100))/100
if   b <= 12 and  a<=12 and a!=0 and b!= 0:
       print("AMBIGUOUS")
elif b <= 12 and b!=0:
       print("MMYY")
elif a<=12 and a!=0  :
       print("YYMM")
else :
      print("NA")

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

Solution (Python):
s = input()
a, b = int(s[:2]), int(s[2:])
ym, my = False, False
if a > 0 and a <13:
    my = True
if b > 0 and b <13:
    ym = True
if ym and my:
    print('AMBIGUOUS')
elif ym and not my:
    print('YYMM')
elif not ym and my:
    print('MMYY')
else:
    print('NA')

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

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=int(input())
a=s//100
b=s%100
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):
a=input()
 
b = int(a[:2])
c = int(a[2:])
 
if 0< b < 13:
    a_month_flag = 1
    
elif b == 0:
    a_month_flag = 0    
else:
    a_month_flag = 0
 
if 0< c < 13:
    b_month_flag = 1
    
elif c == 0:
    b_month_flag = 0
  
else:
    b_month_flag = 0
 
if a_month_flag ==1 and b_month_flag==1:
    print("AMBIGUOUS")
elif a_month_flag == 1 and b_month_flag == 0:
    print("MMYY")
elif a_month_flag == 0 and b_month_flag ==1:
    print("YYMM")
else:
    print("NA")

Solution (Python):
a=input()

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

if 0< b < 13:
    a_month_flag = 1
    a_year_flag = 1
elif b == 0:
    a_month_flag = 0
    a_year_flag = 0
else:
    a_month_flag = 0
    a_year_flag = 1

if 0< c < 13:
    b_month_flag = 1
    b_year_flag = 1
elif c == 0:
    b_month_flag = 0
    b_year_flag = 0
else:
    b_month_flag = 0
    b_year_flag = 1

if a_month_flag ==1 and b_month_flag==1:
    print("AMBIGUOUS")
elif a_month_flag == 1 and b_month_flag == 0:
    print("MMYY")
elif a_month_flag == 0 and b_month_flag ==1:
    print("YYMM")
else:
    print("NA")

Solution (Python):
S = input()

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

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

Solution (Python):
s=int(input())
a=s//100
b=s%100
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()

fir = int(s[:2])
sec = int(s[2:])

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

Solution (Python):
YYMM = False
MMYY = False
f = input()
h1 = f[0] + f[1]
h2 = f[2] + f[3]

if 1 <= int(h2) <= 12:
  YYMM = True
if 1 <= int(h1) <= 12:
  MMYY = True

def ret(c1,c2):
  if c1 and c2:
    return "AMBIGUOUS"
  elif c1:
    return "YYMM"
  elif c2:
    return "MMYY"
  else:
    return "NA"
  
print(ret(YYMM,MMYY))

Solution (Python):
S = input()
l, r =  map(int, [S[:2], S[2:]])

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

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

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

if 1 <= a <= 12 and a <= 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,0]
if 1 <=  int(s[:2]) <= 12:
    ans[0] = 1
if 1 <= int(s[2:]) <= 12:
    ans[1] = 1
print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][ans[0]][ans[1]])

Solution (Python):
S = input()
l,r = int(S[:2]),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=input()
a=int(s[0: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 = int(input())
f = s/100
l = s%100
if 1 <= f and f <= 12:
    if 1 <= l and l <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= l and l <= 12:
        print('YYMM')
    else:
        print('NA')

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

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


if __name__ == '__main__':
    solve()

Solution (Python):
S = input()
months = [i for i in range(1, 13)]
left = int(S[:2])
right = int(S[2:])
if left in months and right in months:
    print('AMBIGUOUS')
elif left in months:
    print('MMYY')
elif right in months:
    print('YYMM')
else:
    print('NA')

Solution (Python):
import sys
A=int(sys.stdin.readline(2))
D=int(sys.stdin.readline(2))
if A>=1 and A<=12:
	if D>=1 and D<=12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
elif D>=1 and D<=12:
	print("YYMM")
else:
	print("NA")

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    S = readline().strip()
    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')

    return


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
for c in s:
    if not '0'<=c<='9':
        print('NA')
        exit(0)
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=list(input())
if s[0]=='0':
  t=int(s[1])
  
else:
  t=int(''.join(s[:2]))
if s[2]=='0':
  u=int(s[3])
else:
  u=int(''.join(s[2:]))

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

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

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

Solution (Python):
S = input()

ans = 'NA'
L = int(S[ : 2])
R = int(S[2 :])

if 13 > L > 0 and 13 > R > 0:
    ans = 'AMBIGUOUS'
elif 13 > R > 0:
    ans = 'YYMM'
elif  13 > L > 0:
    ans = 'MMYY'

print(ans)

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

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

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

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

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

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

if 1<= s1 <=12 and 1<= s2 <= 12:
    print("AMBIGUOUS")

elif 0<= s1 <=99 and 1<= s2 <= 12:
    print("YYMM")

elif 1<= s1 <=12 and 0<= s2 <= 99:
    print("MMYY")

else:
    print("NA")

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

if __name__ == "__main__":
    main()

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

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

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

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

Solution (Python):
s=input()
x=0
y=0
u=int(s[0:2])
d=int(s[2:])

if 1<=u and u<=12:
    x=1
else:
    x=-1
if 1<=d and d<=12:
    y=1
else:
    y=-1
    
if x*y==1 and x<0:
    print('NA')
elif x*y==1:
    print('AMBIGUOUS')
elif x==1 and y==-1:
    print('MMYY')
else:
    print('YYMM')

Solution (Python):


def MMcheck(n):
    return True if 0 < n <= 12 else False

n = str(input())
f2 = int(n[0:2])
l2 = int(n[2:5])
f2check = MMcheck(f2)
l2check = MMcheck(l2)

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

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

p=0
q=0
if S[0]==1:
    if 0<=S[1] and S[1]<=2:
        p=1

if S[0]==0:
    if 1<=S[1] and S[1]<=9:
        p=1

if S[2]==1:
    if 0<=S[3] and S[3]<=2:
        q=1

if S[2]==0:
    if 1<=S[3] and S[3]<=9:
        q=1

if p==0 and q==1:
    print("YYMM")
elif p==1 and q==0:
    print("MMYY")

elif p==1 and q==1:
    print("AMBIGUOUS")
else:
    print("NA")

Solution (Python):
N=input()

MM=0
mm=0


if int(N[0])>1 or (int(N[0])==1 and int(N[1])>2) or N[0:2]=="00":
    MM=0
else:
    MM=1
if int(int(N[2]))>1 or (int(N[2])==1 and int(N[3])>2 or N[2:4]=="00"):
    mm=0
else:
    mm=1

if MM+mm==2:
    print("AMBIGUOUS")
elif MM==1:
    print("MMYY")
elif mm==1:
    print("YYMM")
else:
    print("NA")

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

Solution (Python):
s = input()

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

if f>12:
    if b>0 and b<13:
        print("YYMM")
    else:
        print("NA")

elif f>0 and f<13:
    if b>0 and b<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if b>0 and b<13:
        print("YYMM")
    else:
        print("NA")

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

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

Solution (Python):
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline



def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    s = gete()

    a = (1 <= int(s[:2]) <= 12)
    b = (1 <= int(s[2:]) <= 12)

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


if __name__ == "__main__":
    main()

Solution (Python):
s = input()
a = int(s[:2])
b = int(s[-2:])
ym = True if 1 <= b <= 12 else False
my = True if 1 <= a <= 12 else False
print('AMBIGUOUS' if ym and my else 'YYMM' if ym else 'MMYY' if my else 'NA')

Solution (Python):
S = input()

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

def is_MM(s):
    if 1 <= int(s) <= 12:
        return True
    else:
        return False
    
if is_MM(S1):
    if is_MM(S2):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if is_MM(S2):
        print("YYMM")
    else:
        print("NA")

Solution (Python):
s = raw_input()
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(tuple([(0<int(s[2*i:2*i+2]) <= 12)	for i in range(2)]))))]

Solution (Python):
def f(s):

	return tuple([(0<int(s[2*i:2*i+2]) <= 12)	for i in range(2)])
		
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(f(raw_input()))))]

Solution (Python):
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return (0 < m <= 12,0 < y <= 12)

print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(f(raw_input()))))]

Solution (Python):
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return (0 < m <= 12,0 < y <= 12)

p,q = map(int,list(f(raw_input())))
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[(p,q)]

Solution (Python):
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return 0< m <= 12

def g(s):
  y,m = int(s[:2]), int(s[2:])
  return 0< m <= 12
    
s = raw_input()
p,q = f(s), g(s)

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

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

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

if 1 <= p and p <= 12:
    if 1<= s and s<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")

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

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = input()[:-1].decode()
    l = int(s[:2])
    r = int(s[2:])
    if (l >= 13 or l == 0) and 1 <= r <= 12:
        print('YYMM')
    elif 1 <= l <= 12 and (r >= 13 or r == 0):
        print('MMYY')
    elif 1 <= l <= 12 and 1 <= r <= 12:
        print('AMBIGUOUS')
    else:
        print('NA')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Solution (Python):
S = input()

from datetime import datetime as dt

ans = 0



try:
  x = dt.strptime("20"+S, "%Y%m")
  ans_s = "YYMM"
except:
  ans += 1
try:
  dt.strptime(S[:2] + "20" + S[2:], "%m%Y")
  ans_s = "MMYY"
except:
  ans += 1
  
if ans == 2:
  print("NA")
elif ans == 0:
  print("AMBIGUOUS")
else:
  print(ans_s)

Solution (Python):
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    S = input()
    ym1 = int(S[0:2])
    ym2 = int(S[2:4])

    yymm = (1 <= ym2 and ym2 <= 12)
    mmyy = (1 <= ym1 and ym1 <= 12)

    if yymm and mmyy:
        ans = 'AMBIGUOUS'
    elif yymm:
        ans = 'YYMM'
    elif mmyy:
        ans = 'MMYY'
    else:
        ans = 'NA'

    print(ans)


if __name__ == '__main__':
    solve()

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

f = num[0]*10 + num[1]
b = num[-2]*10 + num[-1]

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

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

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

Solution (Python):
s = input()
n1 = int(s[0:2])
n2 = int(s[2:4])

flag1 = False
flag2 = False
if n1 >= 0 and n2 >= 1 and n2 <= 12:
    flag1 = True
if n1 >= 1 and n1 <= 12 and n2 >= 0:
    flag2 = True

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

Solution (Python):

s = input()

s_f = s[:2]
s_s = s[2:]

if (int(s_f) > 12 or int(s_f) == 0) and (int(s_s) > 12 or int(s_s) == 0):
    print('NA')
elif int(s_f) > 12 or int(s_f) == 0:
    print('YYMM')
elif int(s_s) > 12 or int(s_s) == 0:
    print('MMYY')

else:
    print('AMBIGUOUS')

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

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

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

Solution (Python):
def actual(s):
    left, right = int(s[:2]), int(s[2:])

    valid_right_as_mm = 1 <= right <= 12
    valid_left_as_mm = 1 <= left <= 12

    if valid_left_as_mm and valid_right_as_mm:
        return 'AMBIGUOUS'

    if valid_left_as_mm:
        return 'MMYY'

    if valid_right_as_mm:
        return 'YYMM'

    return 'NA'

s = input()
print(actual(s))

Solution (Python):
import datetime


def actual(s):
    try:
        is_valid_yymm = bool(datetime.datetime.strptime(s, '%y%m'))
    except ValueError:
        is_valid_yymm = False

    try:
        is_valid_mmyy = bool(datetime.datetime.strptime(s, '%m%y'))
    except ValueError:
        is_valid_mmyy = False

    if is_valid_yymm and is_valid_mmyy:
        return 'AMBIGUOUS'

    if is_valid_yymm and not is_valid_mmyy:
        return 'YYMM'

    if not is_valid_yymm and is_valid_mmyy:
        return 'MMYY'

    return 'NA'

s = input()
print(actual(s))

Solution (Python):
s = int(input())
mae   = s // 100
usiro = s % 100
Mflag = True
Uflag = True

if mae < 1 or mae > 12:
    Mflag = False

if usiro < 1 or usiro > 12:
    Uflag = False

if Mflag:
    if Uflag:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if Uflag:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])
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 = input()

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

if (l == 00 and r == 00) or (l>12 and r > 12) or (l == 00 and r > 12) or(l > 12 and r == 00):
    print("NA")
elif l > 12 and r < 13:
    print("YYMM")
elif l < 13 and r > 12:
    print("MMYY")
elif l == 00 and r < 13:
    print("YYMM")
elif l < 13 and r == 00:
    print("MMYY")
elif l <= 12 and r <= 12:
    print("AMBIGUOUS")

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

Solution (Python):
import math
def ips():return input()
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

s=ips()
first=int(s[:2])
second=int(s[2:])
if first<=12 and second<=12 and first>0 and second>0:print("AMBIGUOUS")
elif first<=12 and first>0 :print("MMYY")
elif second<=12 and second>0:print("YYMM")
else:print("NA")

Solution (Python):
S = input()
pre, lat = int(S[0:2]), int(S[2:4])
pre_M = 1 <= pre <= 12
lat_M = 1 <= lat <= 12
if pre_M and lat_M:
  print("AMBIGUOUS")
elif pre_M:
  print("MMYY")
elif lat_M:
  print("YYMM")
else:
  print("NA")