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):
def c(a, b):
    if a is '0':   
        if b is '0':
            return False
    elif a is '1':
        if b is '0'or b is '1' or b is '2':
            return True
        else:
            return False
    else:
        return False
    return True


s = (input())

a = c(s[0],s[1])
b = c(s[2],s[3])

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

Solution (Python):
S=list(input())
XXYY=[]
l=' '
for i in range(2):
    l+=S[i]
XXYY.append(int(l))
l=' '
for i in range(2,4):
    l+=S[i]
XXYY.append(int(l))

ans=[]
if XXYY[0]>12:
    if XXYY[1]<=12 and XXYY[1]>0:
        ans.append("YYMM")
    else:
        ans.append("NA")
elif XXYY[0]<=12 and XXYY[0]>0:
    if XXYY[1]>12:
        ans.append("MMYY")
    elif XXYY[1]<=12 and XXYY[1]>0:
        ans.append("AMBIGUOUS")
    else:
        ans.append("MMYY")
else:
    if XXYY[1]<=12 and XXYY[1]>0:
        ans.append("YYMM")
    else:
        ans.append("NA")
print(ans[0])

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

mmyy = False

if 1 <= s2 <= 12:
    yymm = True
if 1 <= s1 <= 12:
    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()
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):
string=input()
x=int(string[:2]);y=int(string[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):
def check_yy(a, b):
    if a == "0":
        if b == "0":
            return True
    elif a == "1":
        if b in ["3", "4", "5", "6", "7", "8", "9"]:
            return True
    elif a in ["2", "3", "4", "5", "6", "7", "8", "9"]:
        return True
    return False


S = input()

if check_yy(S[0], S[1]):
    if check_yy(S[2], S[3]):
        print("NA")
    else:
        print("YYMM")
elif check_yy(S[2], S[3]):
    print("MMYY")
else:
    print("AMBIGUOUS")

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

Solution (Python):

def check(i):
  i = int(i)
  if 12 < i or i == 0:
    return "YY"
  else:
    return "MM"


S = input().strip()
l, r = map(check, (S[:2], S[2:]))

if l == r:
  if l == "MM":
    print("AMBIGUOUS")
  else:
    print("NA")
else:
  print(l + r)

Solution (Python):
year = int(input())
i = year
lst = []
j=0
while j < 4:
    if(i%10==0):
        lst.append(0)
    else:
        lst.append(i%10)
    i //= 10 
    j+=1

a=lst[3]*10
b=lst[1]*10
c=a+lst[2]
d=b+lst[0]
if(c==0 and d==0):
    print("NA")
if(c>0 and c<13 and d==0):
    print("MMYY")
if(c==0 and d>0 and d<13):
    print("YYMM")
if(c>0 and c<13 and d>0 and d<13):
    print("AMBIGUOUS")
if(c>0 and c<13 and d>12):
    print("MMYY")
if(c>12 and d>0 and d<13):
    print("YYMM")
if(c>12 and d>12):
    print("NA")
if(c>12 and d==0):
    print("NA")
if(c==0 and d>12):
    print("NA")

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

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

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

def func(i):
  if (i==0) | (i>12):
    return 'YY'
  else:
    return 'MM'
  
ans  = func(a) + func(b)
if (ans=='YYMM') | (ans=='MMYY'):
  print (ans)
elif ans=='MMMM':
  print ('AMBIGUOUS')
else:
  print('NA')

Solution (Python):

import sys,datetime



def solve(lines):
    S = lines.pop(0)
    front = int(S[:2])
    back  = int(S[2:])

    try:
        datetime.date(2000 + front, back, 1)
        datetime.date(2000 + back, front, 1)
        print('AMBIGUOUS')
        sys.exit(0)
    except ValueError:
        pass

    try:
        datetime.date(2000 + front, back, 1)
        print('YYMM')
        sys.exit(0)
    except ValueError:
        pass

    try:
        datetime.date(2000 + back, front, 1)
        print('MMYY')
        sys.exit(0)
    except ValueError:
        pass

    print('NA')




lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

Solution (Python):
s=int(input())
a=(s-s%1000)+(s%1000-s%100)
b=s%100
if 100<=a<=1200 and 1<=b<=12:
  print('AMBIGUOUS')
elif 100<=a<=1200 and b>12:
  print('MMYY')
elif a>1200 and 1<=b<=12:
  print('YYMM')
elif a==100 and b==0:
  print('MMYY')
elif a==0 and b==1:
  print('YYMM')
else:
  print('NA')

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

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

if   (f in month) & (a in month):
  print('AMBIGUOUS')
elif (f in month):
  print('MMYY')
elif (a in month):

  print('YYMM')
else:
  print('NA')

Solution (Python):

s = input()
op = ''
first = s[0:2]
second = s[2:4]
if (0 < int(first) <= 12):
	op += 'MM'
else:
	op += 'YY'
if (0 < int(second) <= 12):
	op += 'MM'
else:
	op += 'YY'

if (len(s) != 4):
	op = 'NA'
elif (op == 'MMMM'):
	op = 'AMBIGUOUS'
elif (op == 'YYYY'):
	if ((second == '00' and first == '00') or int(second) > 12 or int(first) > 12):
		op = 'NA'
print(op)

Solution (Python):

"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime
import re

def sol(S):
    
    if re.match("^[0][0][0][0]$", S):
        return 'NA'
    if re.match("^[0][0][0-1][0-2]$", S):
        return 'YYMM'
    if re.match("^[0-1][0-2][0][0]$", S):
        return 'MMYY'
    elif re.match("^[0-1][0-2][0-1][0-2]$", S):
        return 'AMBIGUOUS'
    elif re.match("^[0-9][0-9][1][0-2]$", S):
        return 'YYMM'
    elif re.match("^[0-9][0-9][0][1-9]$", S):
        return 'YYMM'
    elif re.match("^[1][0-2][0-9][0-9]$", S):
        return 'MMYY'
    elif re.match("^[0][1-9][0-9][0-9]$", S):
        return 'MMYY'
    else:
        return 'NA'


do_submit = True


def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    
    
    S = parsed_lines[0][0]
    return S


if not do_submit:
    S = input_parse("""
    1905
    """)
    print(sol(S))

    S = input_parse("""
    0112
    """)
    print(sol(S))

    S = input_parse("""
    1700
    """)
    print(sol(S))

    S = input_parse("""
    0000
    """)
    print(sol(S))

    S = input_parse("""
    1001
    """)
    print(sol(S))



else:
    
    S = input()
    print(sol(S))

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

if 1<=b<=12:
    judge[0] = 1

if 1<=a<=12:
    judge[1] = 1

if sum(judge) == 2:
    print("AMBIGUOUS")
elif sum(judge) == 0:
    print("NA")
elif judge[0] == 1:
    print("YYMM")
else:
    print("MMYY")

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


sf=[sstr[0],sstr[1]]
sb=[sstr[2],sstr[3]]
if sf[0]=="0":
  sf.pop(0)
if sb[0]=="0":
  sb.pop(0)
fws="".join(sf)
bks="".join(sb)
fwb=[int(n) for n in fws]
bkb=[int(n) for n in bks]


if len(fwb)==2:
    fw=(fwb[0]*10)+(fwb[1])
else:
    fw=fwb[0]
if len(bkb)==2:
    bk=(bkb[0]*10)+(bkb[1])
else:
    bk=bkb[0]


if 1<=fw<=12:
  if 1<=bk<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=bk<=12:
    print("YYMM")
  else:
    print("NA")
"""
sstr=list(input())
s=[int(n) for n in sstr]
if s[0]>=2: 
    if s[2]>=2: 
        print("NA")
    elif s[2]==1: 
        if s[3]>=3: 
            print("NA")
        else: 
            print("YYMM")
    else: 
        if s[3]==0: 
            print("NA")
        else: 
            print("YYMM")

elif s[0]==1: 
    if s[1]>=3: 
        if s[2]>=2: 
            print("NA")
        elif s[2]==1: 
            if s[3]>=3: 
                print("NA")
            else: 
                print("YYMM")
        else: 
            if s[3]==0:
                print("NA")
            else:
                print("YYMM")
    else: 
        if s[2]>=2: 
            print("MMYY")
        elif s[2]==1: 
            if s[3]>=3: 
                print("MMYY")
            else: 
                print("AMBIGUOUS")
        else: 
            print("AMBIGUOUS")

else: 
    if s[2]>=2: 
        if s[1]==0:
            print("NA")
        else:
            print("MMYY")
    elif s[2]==1: 
        if s[3]<=2: 
            print("AMBIGUOUS")
        else: 
            print("MMYY")
    else: 
        if s[3]==0: 
            if s[1]==0:
                print("NA")
            else:
                print("MMYY")
        else:
            print("AMBIGUOUS")
            """

Solution (Python):
S = input()
first_half = int(S[:2])
second_half = int(S[2:])

if 1 <= first_half <= 12 and 1 <= second_half <= 12:
    print('AMBIGUOUS')
elif not 1 <= first_half <= 12 and 1 <= second_half <= 12:
    print('YYMM')
elif 1 <= first_half <= 12 and not 1 <= second_half <= 12:
    print('MMYY')
else:
    print('NA')

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

for i in range(4):
    S[i] = int(S[i])

mae = S[0] * 10 + S[1]
usiro = S[2] * 10 + S[3]

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

Solution (Python):
S = input()
S = list(S)
front = S[0] + S[1]
back = S[2] + S[3]

front = int(front)
back = int(back)

hoge = False
onon = False

if front >= 13 or front == 0:
    hoge = True
if back >= 13 or back == 0:
    onon = True   

if hoge == True and onon == True:
    print("NA")
elif hoge == True:
    print("YYMM")
elif onon == True:
    print("MMYY")
else:
    print("AMBIGUOUS")

Solution (Python):
S = input()
K = int(S[0]+S[1])
L = int(S[2]+S[3])
if 1<=K<=12 and 1<=L<=12:
    print("AMBIGUOUS")
if 1<=K<=12 and L == 0:
    print("MMYY")
if 1<=K<=12 and 13<=L<=99:
    print("MMYY")
if K ==0 and L == 0:
    print("NA")
if K == 0 and 1<=L<=12:
    print("YYMM")
if K == 0 and 13<=L<=99:
    print("NA")
if 13<=K<=99 and L == 0:
    print("NA")
if 13<=K<=99 and 1<=L<=12:
    print("YYMM")
if 13<=K<=99 and 13<=L<=99:
    print("NA")

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

Solution (Python):


 
s = input()
MMYY = 0
YYMM = 0
s1 = int(s[0:2])
s2 = int(s[2:4])

if 1 <= s1 <= 12:
        MMYY = 1

if 1 <= s2 <= 12:
        YYMM = 1

if MMYY and YYMM:
        print("AMBIGUOUS")

if MMYY and not YYMM:
        print("MMYY")

if YYMM and not MMYY:
        print("YYMM")

if not YYMM and not MMYY:
        print("NA")

Solution (Python):
S = input()

front = int(S[:2])
back = int(S[2:])

if (front==0) and (back==0):
    print("NA")
elif (front==0) and (back <= 12):
    print("YYMM")
elif (front <= 12) and (back==0):
    print("MMYY")
elif (front <= 12 and front!=0) and (back <= 12 and back!=0):
    print("AMBIGUOUS")
elif (front > 12) and (back <= 12 and back!= 0):
    print("YYMM")
elif (front <= 12 and front!=0) and (back > 12):
    print("MMYY")
else :
    print("NA")

Solution (Python):
def solve():
    S= input()
    ue = int(S[:2])
    sita = int(S[2:])

    ueok = 1 <= ue <= 12
    sitaok = 1 <= sita <= 12
    if ueok and sitaok:
        print("AMBIGUOUS")
    elif not ueok and sitaok:
        print("YYMM")
    elif ueok and not sitaok:
        print("MMYY")
    else:
        print("NA")

if __name__ == "__main__":
    solve()

Solution (Python):

import sys
input = sys.stdin.readline
ymo = input()

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

ans = ""

if a == 0 and b ==0:
    ans = "NA"


elif (a > 12 or a == 0) and 0 < b < 13:
    ans = "YYMM"


elif 0 < a < 13 and (b > 12 or b == 0):
    ans = "MMYY"


elif a <13 and b < 13:
    ans = "AMBIGUOUS"

else :
    ans = "NA"

print(ans)

Solution (Python):
S = input()
if ((int(S[:2]) == 0) and (int(S[2:4])) == 0):
    print("{}".format("NA"))
elif (int(S[:2]) == 0) and (12< int(S[2:4])):
    print("{}".format("NA"))
elif(12< (int(S[:2])) and (int(S[2:4]) == 0)):
    print("{}".format("NA"))
elif (12 < int(S[:2])) and (12 < int(S[2:4])):
      print("{}".format("NA"))
elif(int(S[:2]) == 0) and (int(S[2:4]) < 13):
    print("{}".format("YYMM"))
elif(int(S[:2]) < 13) and (int(S[2:4]) == 0):
    print("{}".format("MMYY"))
elif (0<(int(S[:2]) <13) and (0< int(S[2:4]) < 13)):
    print("{}".format("AMBIGUOUS"))
elif(int(S[:2]) < 13):
     print("{}".format("MMYY"))
else:
     print("{}".format("YYMM"))

Solution (Python):
ans = ''
fmt = input()
n1 = int(fmt[:2])
n2 = int(fmt[2:])

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

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

a = 0
b = 0
if s[0:2] in m:
  a = 1
if s[2:] in m:
  b = 1
  
if a == 0 and b == 0:
  print("NA")
elif a == 1 and b == 0:
  print("MMYY")
elif a == 0 and b == 1:
  print("YYMM")
else:
  print("AMBIGUOUS")

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

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

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

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

Solution (Python):
ls=list(input())
first=[ls[0],ls[1]]
second=[ls[2],ls[3]]

if ls[0]=="0":
    del first[0]
if ls[2]=="0":
    del second[0]

a=int("".join(first))
b=int("".join(second))

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

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

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

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

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

left = int(s[:2])
right = int(s[-2:])


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

Solution (Python):

o1 = False


o2 = False


o3 = False

s = input()
s1 = s[:2]
s2 = s[2:]

if int(s1) <= 12 and int(s1) > 0:
    if int(s2) <= 12 and int(s2) > 0:
        o3 = True
    else:
        o2 = True

if int(s2) <= 12 and int(s2) > 0:
    if int(s1) <= 12 and int(s1) > 0:
        pass
    else:
        o1 = True

if o1 is True:
    print("YYMM")
elif o2 is True:
    print("MMYY")
elif o3 is True:
    print("AMBIGUOUS")
else :
    print("NA")

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

Solution (Python):
if __name__ == '__main__':
    s = int(input())
    y, m = s // 100, s % 100
    if (y == 0 or y > 12) and (m == 0 or m > 12):
        print('NA')
    elif y > 12 or y == 0:
        print('YYMM')
    elif m > 12 or m == 0:
        print('MMYY')
    else:
        print('AMBIGUOUS')

Solution (Python):
from sys import stdin
import numpy as np









N = int(stdin.readline().rstrip().split()[0])
aa = N//100
bb = N%100
a = False
b = False
if 1 <= aa <=12:
  a = True
if 1 <= bb <=12:
  b = True
if a and b:
  print("AMBIGUOUS")
elif not a and b:
  print("YYMM")
elif a and not b:
  print("MMYY")
elif not a and not b:
  print("NA")

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

Solution (Python):
S=input()
mozi_1=int(S[0:2])
mozi_2=int(S[2:4])
if 1<=mozi_1<=12 and 1<=mozi_2<=12:print("AMBIGUOUS")
elif 1<=mozi_1<=12 and (13<=mozi_2<=99 or mozi_2==0):print("MMYY")
elif 1<=mozi_2<=12 and (13<=mozi_1<=99 or mozi_1==0):print("YYMM")
else:print("NA")

Solution (Python):
n = input()

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

def date(n1, n2):
    if n1 == 0 and n2 == 0:
        return 'NA'
    if n1 >= 13 and n2 == 0:
        return 'NA'
    if n1 <= 12 and n2 == 0:
        return 'MMYY'
    if n1 == 0 and n2 >= 13:
        return 'NA'
    if n1 == 0 and n2 <= 12:
        return 'YYMM'
    if n1 >= 13 and n2 >= 13:
        return 'NA'
    if n1 >= 13 and n2 <= 12:
        return 'YYMM'
    if n1 <= 12 and n2 >= 13:
        return 'MMYY'
    if n1 <= 12 and n2 <= 12:
        return 'AMBIGUOUS'


print(date(n1, n2))

Solution (Python):
S = input()

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

if 0 < A <= 12 and 0 < B <= 12:
    print('AMBIGUOUS')
elif not (0 < A <= 12 or 0 < B <= 12):
    print('NA')
elif 0 < A <= 12:
    print('MMYY')
else:
    print('YYMM')

Solution (Python):
s = input()


s1 = s[:2]
s2 = s[2:]




i1 = int(s1)
i2 = int(s2)

i1MM = True
i2MM = True

if i1 > 12 or i1 == 0:
    i1MM = False
if i2 > 12 or i2 == 0:
    i2MM = False

if i1MM and i2MM:
    print("AMBIGUOUS")

if not i1MM and i2MM:
    print("YYMM")

if i1MM and not i2MM:
    print("MMYY")

if not i1MM and not i2MM:
    print("NA")

Solution (Python):
s=[int(i) for i in list(input())]
s1=int(''.join(map(str,[s[0],s[1]])))
s2=int(''.join(map(str,[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()
 
if 1<= int(S[0]+S[1])<=12:
  if 1<= int(S[2]+S[3]) <=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1<= int(S[2]+S[3]) <=12:
    print('YYMM')
  else:  
    print('NA')

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

Solution (Python):
year = int(input())
i = year
lst = []
j=0
while j < 4:
    if(i%10==0):
        lst.append(0)
    else:
        lst.append(i%10)
    i //= 10 
    j+=1

a=lst[3]*10
b=lst[1]*10
c=a+lst[2]
d=b+lst[0]
if(c==0 and d==0):
    print("NA")
if(c>0 and c<13 and d==0):
    print("MMYY")
if(c==0 and d>0 and d<13):
    print("YYMM")
if(c>0 and c<13 and d>0 and d<13):
    print("AMBIGUOUS")
if(c>0 and c<13 and d>12):
    print("MMYY")
if(c>12 and d>0 and d<13):
    print("YYMM")
if(c>12 and d>12):
    print("NA")
if(c>12 and d==0):
    print("NA")
if(c==0 and d>12):
    print("NA")

Solution (Python):
def is_available_yymm(s: str) -> bool:
    return 12 >= int(s[2] + s[3]) >= 1


def is_available_mmyy(s: str) -> bool:
    return 12 >= int(s[0] + s[1]) >= 1


def main():
    s = input()
    yymm = is_available_yymm(s)
    mmyy = is_available_mmyy(s)
    if yymm and mmyy:
        print("AMBIGUOUS")
    elif yymm:
        print("YYMM")
    elif mmyy:
        print("MMYY")
    else:
        print("NA")


if __name__ == '__main__':
    main()

Solution (Python):
def is_yy(st):
    st = int(st)
    if (0 <= st <= 99):
        return True
    return False
    
def is_mm(st):
    st = int(st)
    if (1 <= st <= 12):
        return True
    return False

def get_ans(head, tail):
    if (is_yy(head) and is_mm(tail)) and (is_yy(tail) and is_mm(head)):
        return 'AMBIGUOUS'
    elif (is_yy(head) and is_mm(tail)) and not (is_yy(tail) and is_mm(head)):
        return 'YYMM'
    elif not (is_yy(head) and is_mm(tail)) and (is_yy(tail) and is_mm(head)):
        return 'MMYY'
    else:
        return 'NA'

s = input()
head = s[0:2]
tail = s[2:]
print(get_ans(head, tail))

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

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

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


yymm = 0
mmyy = 0

if int(s / 100) <= 12 and int(s / 100) >= 1:
    mmyy = mmyy + 1

if s % 100 <= 12 and s % 100 >= 1:
    yymm = yymm + 1

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

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

if a > 12:
	if b > 12:
		print("NA")
	elif b > 0:
		print("YYMM")
	else:
		print("NA")

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

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

Solution (Python):



months = [_ for _ in range(1, 13)]
years = [_ for _ in range(0, 100)]

flug = [False] * 4

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


if l in years:
    flug[0] = True

if l in months:
    flug[1] = True

if r in years:
    flug[2] = True

if r in months:
    flug[3] = True

l_y = flug[0]
l_m = flug[1]
r_y = flug[2]
r_m = flug[3]

l_l = [flug[0], flug[1]]
r_r = [flug[2], flug[3]]

if all(flug):
    print('AMBIGUOUS')
elif all(l_l) and r_y == True and r_m == False:
    print('MMYY')
elif all(l_l) and r_y == False and r_m == True:
    print('YYMM')
elif all(r_r) and l_y == True and l_m == False:
    print('YYMM')
elif all(r_r) and l_y == False and l_m ==True:
    print('MMYY')
elif l_y == True and l_m == False and  r_y == False and r_m == True:
    print('YYMM')
elif l_y == False and l_m == True and r_y == True and r_m == False:
    print('MMYY')
else:
    print('NA')

Solution (Python):
a = input()

a = list(a)
b = a[0]+a[1]
c = a[2]+a[3]

b = int(b)
c = int(c)

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

elif c >= 1 and c <= 12:
    print("YYMM")

elif b >= 1 and b <= 12:
    print("MMYY")
    
else:
    print('NA')

Solution (Python):
import sys


def input():
    return sys.stdin.readline()[:-1]









s = int(input())
YY = s // 100
MM = s % 100
if 1 <= YY <= 12 and 1 <= MM <= 12:
    print("AMBIGUOUS")
elif 0 < MM <= 12:
    print("YYMM")
elif 0 < YY <= 12:
    print("MMYY")
else:
    print("NA")

Solution (Python):
s = input()

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

if first == 0 and second == 0:
    print("NA")
else:
    if first > 12 and second <= 12 and second != 0:
        print("YYMM")
    elif first <= 12 and second <= 12:
        if first != 0 and second == 0:
            print("MMYY")
        elif second !=0 and first == 0:
            print("YYMM")
        else:
            print("AMBIGUOUS")
    elif first <= 12:
        print("MMYY")
    else:
        print("NA")

Solution (Python):
S_line = [i for i in input()]
S_line_mae = [S_line[0],S_line[1]]
S_line_ushiro = [S_line[2],S_line[3]]
moji_mae = ''.join(S_line_mae)
moji_ushiro = ''.join(S_line_ushiro)

mae = int(moji_mae)
ushiro = int(moji_ushiro)
if (mae==0 or mae>=13) and ushiro>=1 and ushiro<=12:
  print('YYMM')
elif mae>=1 and mae<=12 and (ushiro==0 or ushiro>=13):
  print('MMYY')
elif mae>=1 and mae<=12 and ushiro>=1 and ushiro<=12:
  print('AMBIGUOUS')
else:
  print('NA')

Solution (Python):

inpnum = int(input())


simo = inpnum % 100

kami = inpnum // 100


swapflag = 0
if kami >= simo :
    kami, simo = simo, kami
    swapflag = 1

if kami == 0:
    if 1 <= simo <= 12 and swapflag == 0:
        print("YYMM")
    elif  1 <= simo <= 12 and swapflag == 1:
        print("MMYY")
    else:
        print("NA")

if 1 <= kami <= 12:
    if 1 <= simo <= 12:
        print("AMBIGUOUS")
    elif 13 <= simo and swapflag == 0:
        print("MMYY")
    elif 13 <= simo and swapflag == 1:
        print("YYMM")

if 13 <= kami:
    print("NA")

Solution (Python):
a = input()

a = list(a)
b = a[0]+a[1]
c = a[2]+a[3]

b = int(b)
c = int(c)

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

elif c >= 1 and c <= 12:
    print("YYMM")

elif b >= 1 and b <= 12:
    print("MMYY")
    
else:
    print('NA')

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

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

Solution (Python):
S=input()
XXX=int(S[0:2])
YYY=int(S[2:4])

YM=False
MY=False


if YYY<13 and YYY>0:
	MY=True


if XXX>0 and XXX<13:
	YM=True


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

Solution (Python):
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]

def solve():
    u = N // 100
    l = N % 100
    if u == 0 and l == 0:
        return 'NA'
    if u == 0:
        if l < 13:
            return 'YYMM'
        else: return 'NA'
    if l == 0:
        if u < 13:
            return 'MMYY'
        else: return 'NA'
    if u > 12:
        if l < 13:
            return 'YYMM'
        else: return 'NA'

    if u < 13:
        if l > 12:
            return 'MMYY'
        else: return 'AMBIGUOUS'
    else:
        return 'NA'

if __name__ == "__main__":
    print(solve())

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

YYMM_or_MMYY = []
YYMM_or_MMYY.append(words[0]+words[1])
YYMM_or_MMYY.append(words[2]+words[3])

YYMM_or_MMYY[0] = int(YYMM_or_MMYY[0])
YYMM_or_MMYY[1] = int(YYMM_or_MMYY[1])


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

Solution (Python):
if __name__ == '__main__':
    s = input()
    ys = 00
    ye = 99
    ms = 1
    me = 12
    s1 = int(s[0:2])
    s2 = int(s[2:])
    yymm = False
    mmyy = False
    if (ys <= s1 <= ye) and (ms <= s2 <= me):
        yymm = True
    if (ms <= s1 <= me) and (ys <= s2 <= ye):
        mmyy = True
    if yymm and mmyy:
        print('AMBIGUOUS')
    elif yymm and not mmyy:
        print('YYMM')
    elif mmyy and not yymm:
        print('MMYY')
    else:
        print('NA')

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

left = int(''.join(S[0:2]))
right = int(''.join(S[2:4]))

if (left > 0 and left < 13) and (right > 0 and right < 13):
  print('AMBIGUOUS')
elif left >= 0 and (right > 0 and right < 13):
  print('YYMM')
elif (left > 0 and left < 13) and right >= 0:
  print('MMYY')
else:
  print('NA')

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

s = 0
t = 0

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

Solution (Python):
s = str(input())
f = int(s[:2])
r = int(s[2:])
if 1<=f<=12:
    if 1<=r<=12:
        ans = 'AMBIGUOUS'
    else:
        ans = 'MMYY'
else:
    if 1<=r<=12:
        ans = 'YYMM'
    else:
        ans = 'NA'
print(ans)

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

MM = ["%02d"%i for i in range(1, 12+1)]


if s1 in MM:
    if s2 in MM:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if s2 in MM:
        print("YYMM")
    else:
        print("NA")

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

if 1<=flont<=12:
    if 1<=back<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1<=back<=12:
    if flont==0 or 13<=flont:
        print("YYMM")
else:
    print("NA")

Solution (Python):
S = input()

if(S[0] == 0):
    Z = int(S[1])
else:
    Z = S[0] + S[1]
    X = int(Z)

if(S[2] == 0):
    K = int(S[3])
else:
    K = S[2] + S[3]
    Y = int(K)

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

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

if first == 0 and second == 0:
    print("NA")
else:
    if first > 12 and second <= 12 and second != 0:
        print("YYMM")
    elif first <= 12 and second <= 12:
        if first != 0 and second == 0:
            print("MMYY")
        elif second !=0 and first == 0:
            print("YYMM")
        else:
            print("AMBIGUOUS")
    elif first <= 12:
        print("MMYY")
    else:
        print("NA")

Solution (Python):

s = input()

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