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 math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")



S = input()

mae = S[:2]
usiro = S[2:]

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

if mae in ms and usiro in ms:
    print("AMBIGUOUS")
elif mae in ms:
    print("MMYY")
elif usiro in ms:
    print("YYMM")
else:
    print("NA")

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

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

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
S=input()
s1=int(S[:2])
s2=int(S[2:])
if (s1>=13 or s1==0) and 1<=s2 and s2<=12:
    print("YYMM")
elif (s2>=13 or s2==0) and 1<=s1 and s1<=12:
    print("MMYY")
elif (s1>=13 or s1==0) and (s2>=13 or s2==0):
    print("NA")
else:
    print("AMBIGUOUS")

Solution (Python):
inp = lambda cast=int: list(map(cast, input().split()))
printf = lambda s='', *args, **kwargs: print(str(s).format(*args), flush=True, **kwargs)
s, = inp(str)
a, b = int(s[:2]), int(s[2:])
if 0 < a <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
elif 0 < a <= 12:
    print('MMYY')
elif 0 < b <= 12:
    print('YYMM')
else:
    print('NA')

Solution (Python):
def yymm(s):
    mm = int(s[2:])
    if mm == 0 or mm > 12:
        return False
    return True


def mmyy(s):
    mm = int(s[:2])
    if mm == 0 or mm > 12:
        return False
    return True


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

Solution (Python):
S = input()

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


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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n,k = LI()
    s = input()
    for i in range(k-1):
        print(s[i],end = "")
    print(s[k-1].lower(),end = "")
    for i in range(k,n):
        print(s[i],end = "")
    print()
    return


def B():
    s = S()
    k = int(s[0])*10+int(s[1])
    l = int(s[2])*10+int(s[3])
    if k == 0:
        if l == 0:
            print("NA")
        elif l < 13:
            print("YYMM")
        else:
            print("NA")
    elif k < 13:
        if l == 0:
            print("MMYY")
        elif l < 13:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if l == 0:
            print("NA")
        elif l < 13:
            print("YYMM")
        else:
            print("NA")


def C():
    n = I()

    return


def D():
    n = I()

    return


def E():
    n = I()

    return


def F():
    n = I()

    return


if __name__ == "__main__":
    B()

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

is_yymm = False
is_mmyy = False

if 0 < int(s[:2]) < 13:
    is_mmyy = True
if 0 < int(s[2:4]) < 13:
    is_yymm = True

ans = ""
if is_yymm and not is_mmyy:
    ans = "YYMM"
elif is_mmyy and not is_yymm:
    ans = "MMYY"
elif is_yymm and is_mmyy:
    ans = "AMBIGUOUS"
else:
    ans = "NA"
print(ans)

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

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


if a > 0 and a <=12:
  mm_first = 1
else: mm_first = 0
if b > 0 and b <= 12:
  mm_second = 1
else: mm_second = 0

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

Solution (Python):
S = input()

mm = ['0' + str(x) for x in range(1,10)] + ['10','11','12']

mmyy = (S[:2] in mm)
yymm = (S[2:] in mm)

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

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

Solution (Python):







import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce


from fractions import gcd

inf = float('inf')

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

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))




S = int(input())

p = S // 100
q = S % 100

def ismonth(x):
    return 1 <= x <= 12

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

Solution (Python):
S = input()

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

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

Solution (Python):
am = 'AMBIGUOUS'
ym = 'YYMM'
my = 'MMYY'
na = 'NA'

s = input()

def isM(ss):
  return 1 <= int(ss) <= 12

def isY(ss):
  return 0 <= int(ss) <= 99

def isYM(ssss):
  return isY(ssss[0:2]) and isM(ssss[2:4])

def isMY(ssss):
  return isM(ssss[0:2]) and isY(ssss[2:4])

print(am if isYM(s) and isMY(s) else ym if isYM(s) else my if isMY(s) else na)

Solution (Python):
s = input()

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

af = False
bf = False
if 1 <= a <= 12:
    af = True
if 1 <= b <= 12:
    bf = True

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

Solution (Python):
S = input()

s1 = 1 <= int(S[0:2]) <= 12
s2 = 1 <= int(S[2:4]) <= 12
if s1 and s2:
    ans = 'AMBIGUOUS'
elif s1:
    ans = 'MMYY'
elif s2:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)

Solution (Python):
S = input()

first = S[:2]
second = S[2:]

cond1 = 1 <= int(first) <= 12
cond2 = 1 <= int(second) <= 12

if cond1 and cond2:
    ans = 'AMBIGUOUS'
elif cond1:
    ans = 'MMYY'
elif cond2:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)

Solution (Python):
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    s = input().rstrip()



    if 1 <= int(s[:2]) <= 12:
        front_flag = True
    else:
        front_flag = False
    if 1 <= int(s[2:]) <= 12:
        back_flag = True
    else:
        back_flag = False
    if front_flag and back_flag:
        print('AMBIGUOUS')
    elif front_flag:
        print('MMYY')
    elif back_flag:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
s = input()
x = [int(s[:2]), int(s[2:])]
y = [False, False]
for i, xi in enumerate(x):
    if 1 <= xi <= 12:
        y[i] = True
if y[0] and y[1]:
    print('AMBIGUOUS')
elif y[0]:
    print('MMYY')
elif y[1]:
    print('YYMM')
else:
    print('NA')

Solution (Python):
import sys

input = sys.stdin.readline
s = input()

if 0 < int(s[0:2]) < 13:
    if 0 < int(s[2:]) < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < int(s[2:]) < 13:
        print('YYMM')
    else:
        print('NA')

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

Solution (Python):
a=input()
b=int(a[:2])
c=int(a[2:])
y=0
m=0
if c>0 and c<13:
    m=1
if b>0 and b<13:
    y=1
if m==1==y:
    print("AMBIGUOUS")
elif m==y==0:
    print("NA")
elif m==1:
    print("YYMM")
else:
    print("MMYY")

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

Solution (Python):
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

s = list(input())
n1 = int(str(s[0])+str(s[1]))
n2 = int(str(s[2])+str(s[3]))
f_yymm = False
f_mmyy = False

if n2 > 0 and n2 < 13:
    f_yymm = True

if n1 > 0 and n1 < 13:
    f_mmyy = True


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

Solution (Python):
def solve(string):
    a, b = map(int, [string[:2], string[2:]])
    a_is_mm = True if 1 <= a <= 12 else False
    b_is_mm = True if 1 <= b <= 12 else False
    if a_is_mm and b_is_mm:
        return "AMBIGUOUS"
    if a_is_mm:
        return "MMYY"
    if b_is_mm:
        return "YYMM"
    return "NA"


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):

s = input()

pre = int(s[0:2])
post = int(s[2:])




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


is_pre_m =  is_m(pre)
is_post_m = is_m(post)

ans = "YYMM" if (not is_pre_m ) and is_post_m \
            else "MMYY" if is_pre_m and not is_post_m \
            else "AMBIGUOUS" if is_pre_m and is_post_m \
            else "NA"

print(ans)

Solution (Python):
s = list(input())
s1 = int(s[0] + s[1])
s2 = int(s[2] + s[3])
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):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()

a = 0  
b = 0  
c = 0  
d = 0  

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

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]






amb = "AMBIGUOUS"
s = input()

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

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

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

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

Solution (Python):
S = input()

YYMM = []
MMYY = []

for y in range(100):
    for m in range(1,13):
        YYMM.append("%02d%02d"%(y, m))

for m in range(1, 13):
    for y in range(100):
        MMYY.append("%02d%02d"%(m, y))

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

Solution (Python):
import numpy as np
words = lambda t : list(map(t, input().split()))

str = input()

first = int(str[:2])
second = int(str[2:])

firstY = True
firstM = 1 <= first and first <= 12
secondY = True
secondM = 1 <= second and second <= 12

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

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

if s1 != 00 and s1 < 13:
    flag1 = True

if s2 != 00 and s2 < 13:
    flag2 = True
    
if flag1 and flag2:
    print("AMBIGUOUS")
elif flag1 and not flag2:
    print("MMYY")
elif not flag1 and flag2:
    print("YYMM")
else:
    print("NA")

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

Solution (Python):
s = input().strip()
yy, mm = int(s[:2]), int(s[2:])

yymm = False
mmyy = False
if 1 <= mm and mm <= 12:
    yymm = True
if 1 <= yy and yy <= 12:
    mmyy = True

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

Solution (Python):
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')

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

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if (self.parent[i] == i):
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if i < j:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)





def main():
    s = input()

    first = False
    second = False

    if 1 <= int(s[:2]) and int(s[:2]) <= 12:
        first = True
    if 1 <= int(s[2:]) and int(s[2:]) <= 12:
        second = True

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


if __name__ == '__main__':
    main()

Solution (Python):
x = input()
x1 = int(x[0:2])
x2 = int(x[2:4])

if 0 < x1 <= 12 and 0 < x2 <= 12:
    print("AMBIGUOUS")
elif 0 < x1 <= 12:
    print("MMYY")
elif 0 < x2 <= 12:
    print("YYMM")
else:
    print("NA")

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    h2 = int(S[:2])
    t2 = int(S[2:])
    hm = False
    tm = False
    if 1 <= h2 <= 12:
        hm = True
    if 1 <= t2 <= 12:
        tm = True

    if hm and tm:
        return 'AMBIGUOUS'
    elif hm:
        return 'MMYY'
    elif tm:
        return 'YYMM'
    return 'NA'


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()

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

answer=0

if a>0 and a<13:
    answer+=2
if b>0 and b<13:
    answer+=1

if answer==0:
    print('NA')
elif answer==1:
    print('YYMM')
elif answer==2:
    print('MMYY')
else:
    print('AMBIGUOUS')

Solution (Python):
S = input()

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

Solution (Python):
S = input()

first = int(S[:2])
second = int(S[2:])

canFirstMM = first >= 1 and first <= 12
canSecondMM = second >= 1 and second <= 12

if canFirstMM and not canSecondMM:
  result = "MMYY"
elif not canFirstMM and canSecondMM:
  result = "YYMM"
elif canFirstMM and canSecondMM:
  result = "AMBIGUOUS"
else:
  result = "NA"
  
print(result)

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

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

Solution (Python):
from datetime import date


S = input()

x = int(S[0:2])
y = int(S[2:4])

try:
    date1 = date(x + 2000, y, 1)
except ValueError:
    date1 = None

try:
    date2 = date(y + 2000, x, 1)
except ValueError:
    date2 = None

if date1 and date2:
    print('AMBIGUOUS')
elif date1 is None and date2 is None:
    print('NA')
elif date1:
    print('YYMM')
elif date2:
    print('MMYY')

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

def f(n):
    if n>=1 and n<=12:
        return True
    else:
        return False

if f(n1) and f(n2):
    print("AMBIGUOUS")
elif f(n1) and (not f(n2)):
    print("MMYY")
elif f(n2) and (not f(n1)):
    print("YYMM")
else:
    print("NA")

Solution (Python):
def is_month(v):
  return (v >= 1 and v <= 12)


yymm = int(input())
a = yymm // 100
b = yymm % 100



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

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

Solution (Python):
s=input()

ym = False
my = False
for i in range(12):
    if int(s[:2]) == (i + 1):
        my = True
    if int(s[2:]) == (i + 1):
        ym = True

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

Solution (Python):
import sys
input = sys.stdin.readline
s = input()
s1 = s[0] + s[1]
s2 = s[2] + s[3]
if int(s1) > 12 or int(s1) == 0:
    if int(s2) > 12 or int(s2) == 0:
        print("NA")
    else:
        print("YYMM")
else:
    if int(s2) > 12 or int(s2) == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Solution (Python):
S = input()

mm = ('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12')

head = S[0:2]
tail = S[2:4]
if head in mm and tail in mm:
    print('AMBIGUOUS')
elif head in mm and tail not in mm:
    print('MMYY')
elif head not in mm and tail in mm:
    print('YYMM')
else:
    print('NA')

Solution (Python):
s = input()
first = int(s[:2])
second = int(s[2:])
fv = (1 <= first <= 12)
sv = (1 <= second <= 12)
if fv and sv:
    print('AMBIGUOUS')
elif fv and not sv:
    print('MMYY')
elif not fv and sv:
    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 = input()
x, y = int(s[:2]), int(s[2:])

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

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

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
if 1 <= int(s[:2]) <= 12:
    if 1 <= int(s[2:]) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if 1 <= int(s[2:]) <= 12:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
S = input()

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

Solution (Python):

import sys


def solve(S: int):
    upper = int(S/100)
    lower = S%100
    
    if upper > 0 and upper < 13:
        if lower > 0 and lower < 13:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    elif lower > 0 and lower < 13:
        print('YYMM')
    else:
        print('NA')
        
    return



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

if __name__ == '__main__':
    main()

Solution (Python):

import sys
a = 'YYMM'
b = 'MMYY'
c = 'AMBIGUOUS'
d = 'NA'

def solve(S: str):
    if 1 <= int(S[:2]) <= 12:
        if 1 <= int(S[2:]) <= 12:
            print(c)
        else:
            print(b)
    else:
        if 1 <= int(S[2:]) <= 12:
            print(a)
        else:
            print(d)
    return



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

if __name__ == '__main__':
    main()

Solution (Python):
s = input()
m = [i for i in range(1, 13)]
if int(s[2:]) in m and int(s[0:2]) in m:
  print("AMBIGUOUS")
elif int(s[2:]) in m:
  print("YYMM")
elif int(s[0:2]) in m:
  print("MMYY")
else:
  print("NA")

Solution (Python):
S = input()

s01 = int(S[0:2])
s23 = int(S[2:4])

a = False
if 0 <= s01 <= 99:
    if 1 <= s23 <= 12:
        a = True

b = False
if 0 <= s23 <= 99:
    if 1 <= s01 <= 12:
        b = True

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

Solution (Python):
S = input()

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

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

Solution (Python):
s = input()

x = s[:2]
y = s[2:]

mmyy = 1 <= int(x) <= 12 and 0 <= int(y) <= 99
yymm = 0 <= int(x) <= 99 and 1 <= int(y) <= 12
if mmyy:
    if yymm:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if yymm:
        print('YYMM')
    else:
        print('NA')

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

top = S // 100
under = S % 100

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

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

Solution (Python):
S = input()

YYMM = 1 <= int(S[-2:]) <= 12
MMYY = 1 <= int(S[:2]) <= 12

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

Solution (Python):
import sys
range = xrange
input = raw_input

s = input()

first = int(s[:2])
second = int(s[2:])

fmonth = 1<=first<=12
smonth = 1<=second<=12

if fmonth and smonth:
    print 'AMBIGUOUS'
elif fmonth:
    print 'MMYY'
elif smonth:
    print 'YYMM'
else:
    print 'NA'

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

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

if a1 in test and a2 in test:
    print("AMBIGUOUS")
elif a1 in test:
    print("MMYY")
elif a2 in test:
    print("YYMM")
else:
    print("NA")

Solution (Python):
S=input()
flag1=True
flag2=True
if int(S[:2]) > 12 or int(S[:2])==0:
    flag1=False
if int(S[2:]) > 12 or int(S[2:])==0:
    flag2=False
if flag1:
    if flag2:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if flag2:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
import math
from functools import reduce

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

s = input()

left = int(s[0:2])
right = int(s[2:4])

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