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):
N=input()
a=int(N[:2])
b=int(N[2:])

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

Solution (Python):
S = input()

s1 = int(S[:2])
s2 = int(S[2:])

f1 = 0
f2 = 0
if s1 in range(1, 13):
    f1 = 1

if s2 in range(1, 13):
    f2 = 1

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

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

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

Solution (Python):
s = input()
h = int(s[0:2])
is_mmyy = (h >= 1) & (h <= 12)
t = int(s[2:4])
is_yymm = (t >= 1) & (t <= 12)

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

Solution (Python):
s = input()
tmp = 0
test1 = int(s[0]+s[1])
test2 = int(s[2]+s[3])

if test2 > 0 and test2 <= 12:
    
    tmp += 1
if test1 > 0 and test1 <= 12:
    tmp += 2
if tmp == 3:
    print("AMBIGUOUS")
elif tmp == 2:
    print("MMYY")
elif tmp == 1:
    print("YYMM")
else:
    print("NA")

Solution (Python):
import sys

a = []
for l in sys.stdin:
    a.append(l)

_input = a[0]

def is_month(x):
    
    if 12 >= x > 0:
        return True
    else:
        return False


input_l = int(_input[:2])
input_r = int(_input[2:])

if is_month(input_l):
    if is_month(input_r):
        result = 'AMBIGUOUS'
    else:
        result = 'MMYY'
else:
    if is_month(input_r):
        result = 'YYMM'
    else:
        result = 'NA'

print(result)

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

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

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

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


def mm(s):
    if int(s) <= 12 and 1 <= int(s):
        return True
    return False


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

Solution (Python):
S = input()
first = int(S[:2])
last = int(S[2:])
if 1 <= first <= 12:
    if 1 <= last <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= last <= 12:
        print('YYMM')
    else:
        print('NA')

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

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

Solution (Python):
s=int(input())  
f = s//100
l = s%100


def detect_yymm(num):
    if (num >=1) & (num <= 12):
        return 1
    else:
        return 0
    
if (detect_yymm(f) == 0) & (detect_yymm(l) == 1):
    print('YYMM')
elif (detect_yymm(f) == 1) & (detect_yymm(l) == 0):
    print('MMYY')
elif (detect_yymm(f) == 1) & (detect_yymm(l) == 1):
    print('AMBIGUOUS')
else:
    print('NA')

Solution (Python):
S = str(input())
months = ['01','02','03','04','05','06',
          '07','08','09','10','11','12']
front = S[:2]
back = S[2:]

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

Solution (Python):
MM = ('01','02','03','04','05','06','07','08','09','10','11','12')

S = str(input())

bool_MMYY = False
bool_YYMM = False
if S[:2] in MM:
  bool_MMYY = True
if S[2:] in MM:
  bool_YYMM = True

if bool_MMYY and bool_YYMM:
  ans = 'AMBIGUOUS'
elif bool_MMYY and (not bool_YYMM):
  ans = 'MMYY'
elif (not bool_MMYY) and bool_YYMM:
  ans = 'YYMM'
elif (not bool_MMYY) and (not bool_YYMM):
  ans = 'NA'
  
print(ans)

Solution (Python):
S = input()

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

def mm(n):
    return 1 <= n <= 12

def yy(n):
    return 0 <= n <= 99

if mm(f) and mm(b) or mm(b) and mm(f):
    print("AMBIGUOUS")
elif mm(f) and yy(b):
    print("MMYY")
elif mm(b) and yy(f):
    print("YYMM")
else:
    print("NA")

Solution (Python):

"""                         
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.
                    
    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 19.05.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()
    






abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0] 
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
def isPrime(n) : 
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True




  



def main():
    
    
    s=si()
    a=s[0]+s[1]
    a=int(a)
    b=s[2]+s[3]
    b=int(b)
    
   
    
    if (a>0 and a<=12) and (b>0 and b<=12):
        print('AMBIGUOUS')
    
    elif (a>0 and a<=12):
        print('MMYY')
    
    elif (b>0 and b<=12):
        print('YYMM')
    
    else:
        print('NA')






BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")



if __name__ == "__main__":
    main()

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

Solution (Python):




def main():
    s = input()
    mm = ['{:0>2}'.format(i+1) for i in range(12)]
    d = 0
    if s[:2] in mm:
        d += 2
    if s[2:] in mm:
        d += 1
    ans = ['NA', 'YYMM', 'MMYY', 'AMBIGUOUS']
    print(ans[d])


if __name__ == '__main__':
    main()

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

f = 0
if 1 <= int(''.join(s[:2])) <= 12:
    f |= 1
if 1 <= int(''.join(s[2:])) <= 12:
    f |= 2

if f == 0:
    print("NA")
elif f == 1:
    print("MMYY")
elif f == 2:
    print("YYMM")
else:
    print("AMBIGUOUS")

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

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

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


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

Solution (Python):
S = input()
a = int(S[:2])
b = int(S[2:])
aa = 0<a and 13>a
bb = 0<b and 13>b
if aa:
    if bb:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if bb:
        print("YYMM")
    else:
        print("NA")

Solution (Python):
s = input()

first = s[0:2]
second = s[2:]

def flg(s):
  if int(s) <= 12 and int(s) > 0:
    return 0
  else:
    return 1

f1 = flg(first)
f2 = flg(second)

if f1 == 0 and f2 == 1:
  print("MMYY")
if f1 == 1 and f2 == 0:
  print("YYMM")
if f1 == 0 and f2 == 0:
  print("AMBIGUOUS")
if f1 == 1 and f2 == 1:
  print("NA")

Solution (Python):
S = input()
pre = int(S[:2])
post = int(S[2:])
preM = pre > 0 and pre < 13
postM = post > 0 and post < 13
if preM and postM:
  print('AMBIGUOUS')
elif preM:
  print('MMYY')
elif postM:
  print('YYMM')
else:
  print('NA')

Solution (Python):
S = input()


word = S

front = S[:2]
back = S[2:]

front_mm = False
if 1 <= int(front)  and int(front) <= 12:
    front_mm = True

back_mm = False
if 1 <= int(back)  and int(back) <= 12:
    back_mm = True

if front_mm and back_mm:
    print('AMBIGUOUS')
if not front_mm and back_mm:
    print('YYMM')
if front_mm and not back_mm:
    print('MMYY')
if not front_mm and not back_mm:
    print('NA')

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

type = 0;
if(S[0:2] in MM):
  type += 1
if(S[2:] in MM):
  type += 2

if(type == 0):
  print("NA")
elif(type == 1):
  print("MMYY")
elif(type == 2):
  print("YYMM")
else:
  print("AMBIGUOUS")

Solution (Python):
S = input()

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

Solution (Python):
def ok(n):
    if n > 0 and n < 13:
        return True
    else:
        return False

s = list(input())
a = int(''.join(s[:2]))
b = int(''.join(s[2:]))
if ok(a) and ok(b):
    print('AMBIGUOUS')
elif ok(a):
    print('MMYY')
elif ok(b):
    print('YYMM')
else:
    print('NA')

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

Solution (Python):
S = input()

foward = int(S[0 : 2])
back = int(S[2 : 4])

foward_MM = False
back_MM = False

if foward >= 1 and foward <= 12:
  foward_MM = True
if back >= 1 and back <= 12:
  back_MM = True

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

Solution (Python):
S=input()
S=[i for i in S]
if (int(S[0]+S[1])>12 or int(S[0]+S[1])==0) and 0<int(S[2]+S[3])<13:
    print("YYMM")
elif (int(S[2]+S[3])>12 or int(S[2]+S[3])==0) and 0<int(S[0]+S[1])<13:
    print("MMYY")
elif 0<int(S[2]+S[3])<13 and 0<int(S[0]+S[1])<13:
    print("AMBIGUOUS")
else:
    print("NA")

Solution (Python):
s = input()
former = int(s[:2])
latter = int(s[2:])

if former > 12 or former < 1:
    if latter > 12 or latter < 1:
        print("NA")
    else:
        print("YYMM")
else:
    if latter > 12 or latter < 1:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Solution (Python):
s = input()
c, d = 0, 0
if '01' <= s[:2] <= '12':
    c = 1
if '01' <= s[2:] <= '12':
    d = 1

if c == d == 0:
    print('NA')
if c == d == 1:
    print('AMBIGUOUS')
if c == 0 and d == 1:
    print('YYMM')
if c == 1 and d == 0:
    print('MMYY')

Solution (Python):
S = input()

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
str = input()

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

mae = str[0:2]
ushiro = str[2:]

if mae in mm and ushiro in mm:
    print('AMBIGUOUS')
elif mae in mm:
    print('MMYY')
elif ushiro in mm:
    print('YYMM')
else:
    print('NA')

Solution (Python):
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

S = SI().strip()

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

YYMM, MMYY = False, False
if S[:2] in months:
    MMYY = True

if S[2:] in months:
    YYMM = True

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

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools, random
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right; sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]
def mi(n): return [wi() for _ in range(n)]
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

s = s()
if s[0:2] == "00":
    if "01" <= s[2:4] <= "12":
        print("YYMM")
    else:
        print("NA")
elif "01" <= s[0:2] <= "12":
    if s[2:4] == "00":
        print("MMYY")
    elif "01" <= s[2:4] <= "12":
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif "13" <= s[0:2] <= "99":
    if s[2:4] == "00":
        print("NA")
    elif "01" <= s[2:4] <= "12":
        print("YYMM")
    else:
        print("NA")

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

Solution (Python):
s=input()
a=int(s[:2])
b=int(s[2:])
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):
def task_b():
    ss = input().strip()
    a = int(ss[:2])
    b = int(ss[2:])
    if 1 <= a <= 12 and 1 <= b <= 12:
      	print('AMBIGUOUS')
    elif 1 <= a <= 12 and not 1 <= b <= 12:
      	print('MMYY')
    elif not 1 <= a <= 12 and 1 <= b <= 12:
    	print('YYMM')
    else:
    	print('NA')
task_b()

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

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

Solution (Python):
s=input()

n1=int(s[:2])
n2=int(s[2:])

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

Solution (Python):
S = input()
HD = int(S[0:2])
TL = int(S[2:])

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

Solution (Python):



import sys

input = sys.stdin.readline

def main():
    s = input()
    if is_m(s[0:2]) and is_m(s[2:4]):
        print("AMBIGUOUS")
    elif is_m(s[0:2]) and not is_m(s[2:4]):
        print("MMYY")
    elif not is_m(s[0:2]) and is_m(s[2:4]):
        print("YYMM")
    else:
        print("NA")


def is_m(i):
    n = int(i)
    return 0 < n and n <= 12

main()

Solution (Python):
S = input()
f = int(S[:2])
g = int(S[2:])
yymm = False
mmyy = False
if f >= 1 and f <= 12:
  mmyy = True
if g >= 1 and g <= 12:
  yymm = True
if yymm:
  if mmyy:
    print("AMBIGUOUS")
  else:
    print("YYMM")
else:
  if mmyy:
    print("MMYY")
  else:
    print("NA")

Solution (Python):
seq = input()
st = int(seq[:2:])
nd = int(seq[2::])

if(st == 0 and nd == 0):
    print("NA")
elif((st<=12 and st>0) and (nd<=12 and nd>0)):
    print("AMBIGUOUS")
elif(st<=12 and st>0):
    print("MMYY")
elif(nd<=12 and nd>0):
    print("YYMM")
else:
    print("NA")

Solution (Python):
S = input()

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

YYMM = True
MMYY = True

if AA > 12 or AA <= 0:
    MMYY = False

if BB > 12 or BB <= 0:
    YYMM = False

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

Solution (Python):
S = input()

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

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

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

s = input()
isMaeMM = False
if (0 < int(s[0:2]) < 13):

    isMaeMM = True
isUshiroMM = False
if (0 < int(s[2:]) < 13):

    isUshiroMM = True
if (isMaeMM):
    if (isUshiroMM):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if (isUshiroMM):
        print("YYMM")
    else:
        print("NA")

Solution (Python):
S = input()

HIGH = int(S[:2])
LOW = int(S[2:])

if 1 <= HIGH <= 12:
	if 1 <= LOW <= 12:
		print('AMBIGUOUS')
	else:
		print('MMYY')
else:
	if 1 <= LOW <= 12:
		print('YYMM')
	else:
		print('NA')

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

Solution (Python):
S=input()
n1,n2=int(S[:2]),int(S[2:])
isy=lambda n: True
ism=lambda n: n<13 and n>0
isyymm = (isy(n1) and ism(n2))
ismmyy = (ism(n1) and isy(n2))

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

Solution (Python):
S = input()

yymm = 1 <= int(S[2:]) <= 12
mmyy = 1 <= int(S[:2]) <= 12

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

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

def month(k):
    for i in range(1,13):
        if k == i:
            return True
            break
    return False

if month(a) == True:
    if month(b) == True:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if month(b) == True:
        print('YYMM')
    else:
        print('NA')

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

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

Solution (Python):




s = input()
front = int(s[0] + s[1])
back = int(s[2] + s[3])
answer = ["NA", "YYMM", "MMYY", "AMBIGUOUS"]
ans = 0
if 1 <= back <= 12:
    ans += 1

if 1 <= front <= 12:
    ans += 2

print(answer[ans])

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

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

ans = 0
if (1 <= s1 <= 12 and 0 <= s2 <=99):
    ans += 1
if (1 <= s2 <= 12 and 0 <= s1 <=99):
    ans += 2

if (ans == 0):
    print("NA")
elif (ans == 1):
    print("MMYY")
elif (ans == 2):
    print("YYMM")
elif (ans == 3):
    print("AMBIGUOUS")

Solution (Python):

import sys

def isM(a):
    return  (a >= 1 and a <= 12)

def solve(S: str):
    a = int(S[0:2])
    b = int(S[2:])

    isA = isM(a)
    isB = isM(b)

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





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

int1 = int(S[0:2])
int2 = int(S[2:4])

YYMM = False
MMYY = False
if (0 <= int1 <= 99) and (1 <= int2 <= 12):
    YYMM = True
if (1 <= int1 <= 12) and (0 <= int2  <= 99):
    MMYY = True
    
if YYMM and MMYY:
    print('AMBIGUOUS')
if YYMM and not MMYY:
    print('YYMM')
if not YYMM and MMYY:
    print('MMYY')
if not YYMM and  not MMYY:
    print('NA')

Solution (Python):
S = input()

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

if 0 < b and b < 13:
    yymm = True
else:
    yymm = False
    
if 0 < f and f < 13:
    mmyy = True
else:
    mmyy = False
    
if yymm and mmyy:
    ans = "AMBIGUOUS"
elif yymm:
    ans = "YYMM"
elif mmyy:
    ans = "MMYY"
else:
    ans = "NA"
    
        
print(ans)

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

Solution (Python):
S = input()

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

am = False
bm = False
if a >= 1 and a <= 12:
  am = True
if b >= 1 and b <= 12:
  bm = True

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

Solution (Python):
S = input()

s1 = int(S[:2])
s2 = int(S[2:])



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

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

print("NA")

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

str = "NA"

if S%100 > 0 and S%100 < 13:
    str = "YYMM"

if int(S/100) > 0 and int(S/100) < 13:
    if str == "YYMM":
        str = "AMBIGUOUS"
    else:
        str ="MMYY"

print(str)

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

if 0 < A < 13:
    AisM = True
else:
    AisM = False
    
if 0 < B < 13:
    BisM = True
else:
    BisM = False
    
if AisM and BisM:
    print('AMBIGUOUS')
elif AisM and not BisM:
    print('MMYY')
elif not AisM and BisM:
    print('YYMM')
else:
    print('NA')

Solution (Python):
def canb_month(num):
    if 0 < num and num <= 12:
        return True
    else:
        return False


s = input()
f_half = int(s[:2])
s_half = int(s[2:])

a = None
if canb_month(f_half) and canb_month(s_half):
    a = 'AMBIGUOUS'
else:
    if canb_month(f_half):
        a = 'MMYY'
    elif canb_month(s_half):
        a = 'YYMM'
    else:
        a = 'NA'
        
print(a)

Solution (Python):

s = input()

mm = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
if s[:2] in mm and s[2:] in mm:
  print('AMBIGUOUS')
elif s[:2] in mm:
  print('MMYY')
elif s[2:] in mm:
  print('YYMM')
else:
  print('NA')

Solution (Python):
line = input()
n1 = int(line[:2])
n2 = int(line[2:])
if n1 > 12 or n1 == 0:
	v1 = False
else:
	v1 = True
if n2 > 12 or n2 == 0:
	v2 = False
else:
	v2 = True
if v1 and v2:
	print("AMBIGUOUS")
elif v1 and not v2:
	print("MMYY")
elif not v1 and v2:
	print("YYMM")
else:
	print("NA")

Solution (Python):

def main():
    buf = input()
    S = buf
    first = int(S[0:2])
    second = int(S[2:4])
    if first == 0 and second == 0:
        print('NA')
        return
    elif 1 <= first and first <= 12:
        if 1 <= second and second <= 12:
            print('AMBIGUOUS')
            return
        else:
            print('MMYY')
            return
    elif 1 <= second and second <= 12:
        print('YYMM')
        return
    else:
        print('NA')
        return

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
f = n//100
s = n % 100
ans = "NA"
v = 0
if f in range(1, 13) and s in range(0, 100):
	v += 1
	ans = "MMYY"

if s in range(1, 13) and f in range(0, 100):
	v += 1
	ans = "YYMM"

if v > 1 :
	ans = "AMBIGUOUS"

print(ans)

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

Solution (Python):
S = input()


def f(s):
    return '01' <= s <= '12'


ans = (
    'NA' if not f(S[:2]) and not f(S[2:]) else
    'MMYY' if f(S[:2]) and not f(S[2:]) else
    'YYMM' if not f(S[:2]) and f(S[2:]) else
    'AMBIGUOUS'
)

print(ans)

Solution (Python):
S = list(input())
a = int("".join(S[0:2]))
b = int("".join(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()

firsthalf = int(S[:2])
lasthalf = int(S[2:])

if lasthalf <= 12 and lasthalf >= 1:
    if firsthalf > 12 or firsthalf == 0:
        ans = "YYMM"
    else:
        ans = "AMBIGUOUS"
else:
    if firsthalf == 0 or firsthalf > 12:
        ans = "NA"
    else:
        ans = "MMYY"

print(ans)

Solution (Python):
S = list(input())
yymm=False
mmyy=False

if 0 < int("".join(S[2:])) <= 12:
    yymm = True

if 0 < int("".join(S[:2])) <= 12:
    mmyy = True

if yymm and not mmyy:
    print("YYMM")
elif not yymm and mmyy:
    print("MMYY")
elif yymm and mmyy:
    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 = list(input())
for i in range(len(s)):
    s[i] = int(s[i])

def f(x,y):
    if x == 0:
        if y == 0:
            return 0
        return 1
    elif x == 1:
        if y <= 2:
            return 1
    return 0

fi = f(s[0],s[1])
se = f(s[2],s[3])

if fi < 0 or se < 0:
    print('NA')
elif fi == 0:
    if se == 0:
        print('NA')
    else:
        print('YYMM')
elif se == 0:
    print('MMYY')
else:
    print('AMBIGUOUS')

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

Solution (Python):
Ss = input()

isMM1 = '01' <= Ss[:2] <= '12'
isMM2 = '01' <= Ss[2:] <= '12'

if isMM1:
    if isMM2:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if isMM2:
        print('YYMM')
    else:
        print('NA')