Problem:
 Score : 200 points    Problem Statement You have a digit sequence S of length 4 . You are wondering which of the following formats S is in:   YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order  MMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order   If S is valid in only YYMM format, print YYMM ; if S is valid in only MMYY format, print MMYY ; if S is valid in both formats, print AMBIGUOUS ; if S is valid in neither format, print NA .      Constraints  S is a digit sequence of length 4 .         Input Input is given from Standard Input in the following format:  S       Output Print the specified string: YYMM , MMYY , AMBIGUOUS or NA .        Sample Input 1 1905      Sample Output 1 YYMM  May XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.       Sample Input 2 0112      Sample Output 2 AMBIGUOUS  Both December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.       Sample Input 3 1700      Sample Output 3 NA  Neither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.

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

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

Solution (Python):

"""
Created on Wed May 13 12:19:27 2020

@author: shinba
"""

s = input()

B1 = (s[0] == "0" and s[1] != "0") or (s[0] == "1" and 0 <= int(s[1]) <= 2)
B2 = (s[2] == "0" and s[3] != "0") or (s[2] == "1" and 0 <= int(s[3]) <= 2)

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

Solution (Python):
def chk(innum):
  if 1<=innum and innum<=12:
    return "MM"
  elif 0<=innum and innum<=99:
    return "YY"

s=input()
front=int(s[0:2])
back=int(s[2:4])
ans=chk(front)+chk(back)
if ans=="YYYY":
  ans="NA"
elif ans=="MMMM":
  ans="AMBIGUOUS"
print(ans)

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

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

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


if __name__ == "__main__":
    main()

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

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

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')

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

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

if 12>=f>=1 and 12>=l>=1:
    k=3
elif not(12>=f>=1) and 12>=l>=1:
    k=1
elif not(12>=l>=1) and 12>=f>=1:
    k=2
else:
    k=4
ans=['','YYMM','MMYY','AMBIGUOUS','NA']
print(ans[k])

Solution (Python):
S = input()
a = S[:2]
b = S[2:]
ans = ""
if 1<=int(a)<=12: ans += "MM"
else: ans += "YY"
if 1<=int(b)<=12: ans += "MM"
else: ans += "YY"

if ans in ["YYMM", "MMYY"]: print(ans)
elif ans == "MMMM": print("AMBIGUOUS")
else: print("NA")

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

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

Solution (Python):
s = input()

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

Solution (Python):
S = input()

def is_yymm(s):
    if 1<=int(s)<=12:
        return "both"
    else:
        return "YY"

left = is_yymm(S[:2])
right = is_yymm(S[2:])

ans = left + right

if ans=="YYboth":
    print("YYMM")
elif ans=="bothYY":
    print("MMYY")
elif ans=="bothboth":
    print("AMBIGUOUS")
else:
    print("NA")

Solution (Python):
S = input()
mae = S[0:2]
ato = S[2:4]
smae = int(mae)
sato = int(ato)

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

Solution (Python):
S = input()

Ucheck=S[2:4]

Ucheck=int(Ucheck)
Tcheck=S[0:2]

Tcheck=int(Tcheck)
YYMM="NO"
MMYY="NO"



if Ucheck!=0 and Ucheck<13:
    YYMM="OK"
if Tcheck!=0 and Tcheck<13:
    MMYY="OK"

if YYMM=="OK" and MMYY=="NO":
    print("YYMM")
elif YYMM=="NO" and MMYY=="OK":
    print("MMYY")
elif YYMM=="OK" and MMYY=="OK":
    print("AMBIGUOUS")
else:
    print("NA")

Solution (Python):
s=input()

str_1 = s[:2]
flg_1=0
if str_1 in ['01','02','03','04','05','06','07','08','09','10','11','12']:
    flg_1=1

str_2 = s[2:]
flg_2=0
if str_2 in ['01','02','03','04','05','06','07','08','09','10','11','12']:
    flg_2=1

if flg_1==1 and flg_2==1:
    print('AMBIGUOUS')
elif flg_1==1 and flg_2==0:
    print('MMYY')
elif flg_1==0 and flg_2==1:
    print('YYMM')
else:
    print('NA')

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

if before == 0 or before > 12:
    if after >= 1 and after <= 12:
        print('YYMM')
    else:
        print('NA')
else:
    if after >= 1 and after <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


s = S()
a = int(s[:2])
b = int(s[2:])
if 1 <= a <= 12:
    aMM = True
else:
    aMM = False

if 1 <= b <= 12:
    bMM = True
else:
    bMM = False

if aMM and bMM:
    print("AMBIGUOUS")
elif aMM and not bMM:
    print("MMYY")
elif not aMM and bMM:
    print("YYMM")
else:
    print("NA")

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


if 0<forward<=12:
    if 0<backward<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
if 0<backward<=12:
    if 0==forward or forward>12:
        print("YYMM")
if (0==forward or forward>12) and (0==backward or backward>12):
    print("NA")

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

Solution (Python):
S = str(input())
s1,s2 = int(S[:2]),int(S[2:])
c1,c2 = 0,0

if 0 < s1 < 13:
  c1 = 1
if 0 < s2 < 13:
  c2 = 1

if c1 and c2:
  ans = "AMBIGUOUS"
elif c1:
  ans = "MMYY"
elif c2:
  ans = "YYMM"
else:
  ans = "NA"
print(ans)

Solution (Python):
s = input()

u = int(s[:2])
d = int(s[2:])

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

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

Solution (Python):
s = input()
mae = int(s[:2])
ush = int(s[2:])

if 1<=mae<=12:
    if 1<=ush<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=ush<=12:
        print('YYMM')
    else:
        print('NA')

Solution (Python):


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

S = str(input())
left = S[0] + S[1]
right = S[2] + S[3]

if left not in month and right not in month:
    print('NA')
else:
    if (left in month and left in year) and (right in month and right in year):
        print('AMBIGUOUS')
    else:
        if left in year and right in month:
            print('YYMM')
        else:
            print('MMYY')

Solution (Python):
S = input()
f = int(S[:2])
l = int(S[2:])

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

Solution (Python):
S = input()
left = S[:2]
right = S[2:]

if "01" <= left <= "12" and "01" <= right <= "12":
    print("AMBIGUOUS")
elif "01" <= left <= "12":
    if "00" <= right <= "99":
        print("MMYY")
    else:
        print("NA")
elif "01" <= right <= "12":
    if "00" <= left <= "99":
        print("YYMM")
    else:
        print("NA")
else:
    print("NA")

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

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

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

Solution (Python):
s = input()

n = 4

mae = int(s[:2])
ato = int(s[2:])

if mae < 13 and mae > 0:
    if ato < 13 and ato > 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if ato < 13 and ato > 0:
        print("YYMM")
    else:
        print("NA")

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

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

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

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

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

Solution (Python):

s = input()

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

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

Solution (Python):
s = input()

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

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

Solution (Python):
def yymm_or_mmyy(s):

    ans = ""
    flag1 = False
    flag2 = False

    for i in range(1, 13):
        if s[0:2] == str(i).zfill(2):
            flag1 = True
        if s[2:4] == str(i).zfill(2):
            flag2 = True

    if flag1 and flag2:
        ans = "AMBIGUOUS"
    elif flag1:
        ans = "MMYY"
    elif flag2:
        ans = "YYMM"
    else:
        ans = "NA"

    return ans

def main():
    s = str(input())
    print(yymm_or_mmyy(s))

if __name__ == '__main__':
    main()

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

head = int("".join(S[:2]))
tale = int("".join(S[2:]))

if 1 <= head <= 12:
    if 1 <= tale <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1 <= tale <= 12:
    print("YYMM")
else:
    print("NA")

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

Solution (Python):


def main():
    S = input()
    a, b = int(S[:2]), int(S[2:])
    
    can_a_be_month = 1 <= a <= 12
    can_b_be_month = 1 <= b <= 12
    if can_a_be_month and can_b_be_month:
      print('AMBIGUOUS')
    elif can_a_be_month:
      print('MMYY')
    elif can_b_be_month:
      print('YYMM')
    else:
      print('NA')


if __name__ == '__main__':
    main()

Solution (Python):


s = int(input())
aa = s // 100
bb = s %  100
if 1 <= aa and aa <= 12:
    if 1 <= bb and bb <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= bb and bb <= 12:
        print('YYMM')
    else:
        print('NA')

Solution (Python):

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    s1=int(s[:2])
    s2=int(s[2:])
    l=list(range(1,13))
    if s1 in l and s2 in l:
        print('AMBIGUOUS')
    elif s1 in l and s2 not in l:
        print('MMYY')
    elif s1 not in l and s2 in l:
        print('YYMM')
    else:
        print('NA')
resolve()

Solution (Python):

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

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

Solution (Python):
s = input()
l = s[0]+s[1]
r = s[2]+s[3]
mm = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
if mm.count(l) == 1 and mm.count(r) == 1:
    print('AMBIGUOUS')
elif mm.count(l) == 1 and mm.count(r) != 1:
    print('MMYY')
elif mm.count(l) != 1 and mm.count(r) == 1:
    print('YYMM')
else:
    print('NA')

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

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

def ismonth(x):
    return 0 < x and x < 13

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

Solution (Python):
s = input()

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

p = False
q = False
if 1 <= a <= 12:
  p = True
if 1 <= b <= 12:
  q = True
    
if p and q:
  print("AMBIGUOUS")
if p and not q:
  print("MMYY")
if not p and q:
  print("YYMM")
if not p and not q:
  print("NA")

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

Solution (Python):
S = input()
f = int(S[:2])
s = int(S[2:])
t1 = False
t2 = False
if(f > 0 and f < 13):
    t1 = True
if(s > 0 and s < 13):
    t2 = True
if(t1 == True):
    if(t2 == True):print('AMBIGUOUS')
    else:print('MMYY')
else:
    if(t2 == True):print('YYMM')
    else:print('NA')

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

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

Solution (Python):
n=input()

m=n[0]+n[1]

o=n[2]+n[3]

x=int(m)
y=int(o)

if x>0 and x<13 and y>0 and y<13:
    print("AMBIGUOUS")

elif (x<13 and x>0) and (y>12 or y==0):
    print("MMYY")
elif (x>12 or x==0) and (y<13 and y>0):
    print("YYMM")

elif x==0 or y==0 or x>12 or y>12:
    print("NA")

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

if (A<=12 and A>0) and (B>12 or B==0):
    strFormat = "MMYY"
elif (A>12 or A==0) and (B<=12 and B>0):
    strFormat = "YYMM"
elif (A>0 and A<=12 and B>0 and B<=12 ):
    strFormat = "AMBIGUOUS"
else:
    strFormat = "NA"

print(strFormat)

Solution (Python):
s = int(input())
a = s//100
b = s%100
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 = list(input())
s1 = ''.join(s[:2])
s2 = ''.join(s[2:])
flag1 = False
flag2 = False
if 1 <= int(s1) and int(s1) <= 12:
  flag1 = True
if 1 <= int(s2) and int(s2) <= 12:
  flag2 = True
if flag1 and flag2:
  print('AMBIGUOUS')
elif flag1:
  print('MMYY')
elif flag2:
  print('YYMM')
else:
  print('NA')

Solution (Python):
a=str(input())
f=int(a[0:2])
r=int(a[2:4])
if f>=1 and f<=12:
    f1=True
else:
    f1=False

if r>=1 and r<=12:
    r1=True
else:
    r1=False

if f1==True and r1==True:
    print('AMBIGUOUS')
if f1==True and r1==False:
    print('MMYY')
if f1==False and r1==True:
    print('YYMM')
if f1==False and r1==False:
    print('NA')

Solution (Python):
s = str (input())
bflag = True
lflag = True
if not(s[0] + s[1] in ['01','02','03','04','05','06','07','08','09','10','11','12']):
    bflag = False
if not(s[2] + s[3] in ['01','02','03','04','05','06','07','08','09','10','11','12']):
    lflag = False
if bflag:
    if lflag:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if lflag:
        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 accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = INT()

if 0 < S%100 <= 12:
	if 0 < S//100 < 12:
		print("AMBIGUOUS")
	else:
		print("YYMM")
elif  0 < S//100 <= 12:
	print("MMYY")
else:
	print("NA")

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

l = ['', '']
for i in range(2):
    if (1 <= s[i] <= 12):
        l[i] = 'MM'
    else:
        l[i] = 'YY'
else:
    if (l.count('MM') == 2):
        print('AMBIGUOUS')
    elif (l.count('MM') == 1):
        print(l[0]+l[1]) 
    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 and (12<b or b==0):
	print("MMYY")
elif (12<a or a==0) and 1<=b<=12:
	print("YYMM")
else:
	print("NA")

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

Solution (Python):
s = input()
ym = False
my = False

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

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

Solution (Python):
S = input()
YY = int(S[0:2])
MM = int(S[2: ])

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

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

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

Solution (Python):
import sys
import math
from collections import Counter
import itertools



def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



S=SR()
ym=0
my=0
if int(S[2:]) >0 and int(S[2:]) <13:
    ym=1
if int(S[:2]) >0 and int(S[:2]) <13:
    my=1

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

Solution (Python):
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd 
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) 

s = int(input())
up = s//100
dn = s - up*100
yymm = (0 < int(dn) <= 12)
mmyy = (0 < int(up) <= 12)
if yymm:
    if mmyy:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if mmyy:
        print('MMYY')
    else:
        print('NA')

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

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

Solution (Python):
S = input()
S = [int(s) for s in S]
yymm = 0
mmyy = 0

if (S[0] == 0 and 0 <= S[1] <= 9) or (1 <= S[0] and 0 <= S[1] <= 9):
    if (S[2] == 0 and 1 <= S[3] <= 9) or (1 == S[2] and 0 <= S[3] <= 2):
        yymm = 1
if (S[0] == 0 and 1 <= S[1] <= 9) or (1 == S[0] and 0 <= S[1] <= 2):
    if (S[2] == 0 and 0 <= S[3] <= 9) or (1 <= S[2] and 0 <= S[3] <= 9):
        mmyy = 1

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

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

if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")

elif 1 <= b <= 12:
    print("YYMM")

elif 1 <= a <= 12:
    print("MMYY")

else:
    print("NA")

Solution (Python):
a,b,c,d=input()
x=int(a+b)
y=int(c+d)
if 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')

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

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

Solution (Python):

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

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

Solution (Python):
S = input()

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

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

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

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

if 1 <= int(S1) <= 12:
    if 1 <= int(S2) <= 12:
        print('AMBIGUOUS')
        exit()
    else:
        print('MMYY')
        exit()

if 1 <= int(S2) <= 12:
    if 1 <= int(S1) <= 12:
        print('AMBIGUOUS')
        exit()
    else:
        print('YYMM')
        exit()

print('NA')

Solution (Python):
S = input()

M1_ = True if int(S[:2]) in range(1, 13, 1) else False
M2_ = True if int(S[2:]) in range(1, 13, 1) else False

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

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

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

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

Solution (Python):
s=input()

x=int(s[:2])
y=int(s[2:])

if (1<=x<=12) and (1<=y<=12):
    print('AMBIGUOUS')

elif (x==0 or x>12) and (1<=y<=12):
    print('YYMM')

elif (1<=x<=12) and (y==0 or y>12):
    print('MMYY')

else:
    print('NA')

Solution (Python):
s=input()

x=int(s[:2])
y=int(s[2:])

if (1<=x and x<=12) and (1<=y and y<=12):
    print('AMBIGUOUS')

elif (x==0 or x>12) and (1<=y and y<=12):
    print('YYMM')

elif (1<=x and x<=12) and (y==0 or y>12):
    print('MMYY')

else:
    print('NA')

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

if 1<= a <=12 and 1<= b <= 12:
    print("AMBIGUOUS")

elif 1<= b <= 12:
    print("YYMM")

elif 1 <= a <= 12:
    print("MMYY")

else:
    print("NA")

Solution (Python):


s = input()
s12 = int(s[0:2])
s34 = int(s[2:])

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

Solution (Python):
def q2():
    S = int(input())
    d, m = divmod(S, 100)

    is_YYMM, is_MMYY = False, False
    if 1 <= d <= 12:
        is_MMYY = True
    if 1 <= m <= 12:
        is_YYMM = True

    if is_MMYY:
        if is_YYMM:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    else:
        if is_YYMM:
            print('YYMM')
        else:
            print('NA')


if __name__ == '__main__':
    q2()

Solution (Python):
s = input()

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

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

if a_mm_flag:
    if b_mm_flag:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if b_mm_flag:
        ans = "YYMM"
    else:
        ans = "NA"

print(ans)

Solution (Python):
s = input()

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

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

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

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

if (first > 0 and first < 13) and (second > 0 and second < 13):
    print("AMBIGUOUS")
elif (first > 0 and first < 13): 
    print("MMYY")
elif (second > 0 and second < 13):
    print('YYMM')
else:
    print('NA')

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

A = S//100
B = S%100

if A >= 13 or A == 0:
    if B >= 13:
        print('NA')
    elif B <13:
        if B != 0:
            print('YYMM') 
        else:
            print('NA')
elif A < 13:
    if B >= 13:
            print('MMYY')
    elif B < 13:
        if B != 0:
            print('AMBIGUOUS')
        else:
            print('MMYY')

Solution (Python):


import sys



















def main():
    mod = 1000000007                  
    inf = float('inf')
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    def check_yymm(s):
        return 1 <= int(s[2:]) <= 12
    
    def check_mmyy(s):
        return 1 <= int(s[:2]) <= 12
    
    s = input()
    if check_mmyy(s) and check_yymm(s):
        print('AMBIGUOUS')
    elif check_mmyy(s):
        print('MMYY')
    elif check_yymm(s):
        print('YYMM')
    else:
        print('NA')


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
front=n//100
back=n%100
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")

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

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

elif (0 < s01 and s01 <= 12) and (s23 > 12 or s23 == 0):
    print('MMYY')

elif (s01 > 12 or s01 == 0) and (0 < s23 and s23 <= 12):
    print('YYMM')
else:
    print('NA')