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.



Sample input:
1905


Sample output:
YYMM

Submission status: Accepted

Solution code:
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('YYMM')
elif YYMM!=1 and MMYY==1:
    print('MMYY')
elif YYMM==1 and MMYY==1:
    print('AMBIGUOUS')
else:
    print('NA')

Submission status: Accepted

Solution code:
s = input()
left = int(s[:2])
right = int(s[2:])

if left == 0:
    if right == 0:
        print("NA")
    elif right < 13:
        print("YYMM")
    else:
        print("NA")
    exit()
if right == 0:
    if left < 13:
        print("MMYY")
    else:
        print("NA")
    exit()

if left < 13 and right < 13:
    print("AMBIGUOUS")
elif left < 13 and right > 12:
    print("MMYY")
elif left > 12 and right < 13:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
S = input()

first = int(S[0:2])
last = int(S[2:4])

if 1 <= first <= 12:
    if 1 <= last <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= last <= 12:
        print("YYMM")
    else:
        print("NA")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

S = int(input())
mae = S//100
ato = S%100

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

Submission status: Accepted

Solution code:
S = input()
AA = int(S[:2])
BB = int(S[2:])

def check(num):
    if 1<=num<=12:
        return True
    else:
        return False
    
if check(AA) and check(BB):
    print("AMBIGUOUS")
elif check(AA):
    print("MMYY")
elif check(BB):
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

def isMonth(n):
	return n <=12 and n > 0
a = isMonth(int(s[:2]))
b = isMonth(int(s[2:]))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()

def can_be_mm(s):
    num = int(s[1])
    if s[0] == '0':
        if num != 0:
            return True
    elif s[0] == '1':
        if num >= 0 and num <= 2:
            return True
    return False

yymm = can_be_mm(S[2:])
mmyy = can_be_mm(S[:2])

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

Submission status: Accepted

Solution code:
a = list(input())

f = int("".join(a[0]+a[1]))
g = int("".join(a[2]+a[3]))
if 1<= f and f <= 12:
     if 1<= g and g <= 12:
          print("AMBIGUOUS")
     else:
          print("MMYY")
elif 1<= g and g <= 12:     
     print("YYMM")
else:
     print("NA")

Submission status: Accepted

Solution code:
S = input()

def M(s):
    return s > 0 and s <= 12


S1,S2 = int(S[:2]),int(S[2:])
if M(S1) and M(S2):
    print("AMBIGUOUS")
elif M(S1):
    print("MMYY")
elif M(S2):
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
s=input()
fst,snd=s[:2],s[2:]
def m(s_):
    if int(s_) <= 12 and int(s_) > 0:
        return True
    return False

if m(fst) and m(snd):
    print("AMBIGUOUS")
elif m(fst):
    print("MMYY")
elif m(snd):
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
S = list(input())
for i in range(4):
    S[i] = int(S[i])


flag1 = 0
if S[0] == 1:
    if S[1] <= 2:
        flag1 = 1
if S[0] == 0:
    if S[1] != 0:
        flag1 = 1

flag2 = 0
if S[2] == 1:
    if S[3] <= 2:
        flag2 = 1
if S[2] == 0:
    if S[3] != 0:
        flag2 = 1

if flag1 == 0 and flag2 == 0:
    print("NA")
if flag1 == 1 and flag2 == 0:
    print("MMYY")
if flag1 == 0 and flag2 == 1:
    print("YYMM")
if flag1 == 1 and flag2 == 1:
    print("AMBIGUOUS")

Submission status: Accepted

Solution code:
s = input()
x = int(s[0:2])
y = int(s[2:4])
if 1 <= x <= 12 and (y == 0 or 13 <= y <= 99):
    print("MMYY")
elif 1 <= y <= 12 and (x == 0 or 13 <= x <= 99):
    print("YYMM")
elif 1 <= x <= 12 and 1 <= y <= 12:
    print("AMBIGUOUS")
else:
    print("NA")

Submission status: Accepted

Solution code:
S = [int(x) for x in list(input())]
f,b = S[0]*10 + S[1], S[2]*10 + S[3]

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

Submission status: Accepted

Solution code:
S = input()
y1, m1 = int(S[:2]), int(S[2:])
y2, m2 = int(S[2:]), int(S[:2])
if 1 <= m1 <= 12 and 1 <= m2 <= 12:
    print("AMBIGUOUS")
elif 1 <= m1 <= 12:
    print("YYMM")
elif 1 <= m2 <= 12:
    print("MMYY")
else:
    print("NA")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
	s = input()
	a = int(s[:2])
	b = int(s[2:])
	x = (a == 0 or a > 12)
	y = (b == 0 or b > 12)
	if x and y:
		print("NA")
	elif not x and not y:
		print("AMBIGUOUS")
	elif x:
		print("YYMM")
	else:
		print("MMYY")
	return 0

main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

def can_mm(n):
  return 1 <= n and n <= 12

def main():
  S = input()
  a = int(S[:2])
  b = int(S[2:])
  if can_mm(a) and can_mm(b):
    print("AMBIGUOUS")
  elif can_mm(a):
    print("MMYY")
  elif can_mm(b):
    print("YYMM")
  else:
    print("NA")

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
a,b,c,d=input()
n,m=int(a+b),int(c+d)
if((1<=m<=12) and (1<=n<=12)):
    print('AMBIGUOUS')
elif((1<=m<=12)):
    print('YYMM')
elif((1<=n<=12)):
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

Solution code:
S=input()
S1=int(S[0:2])
S2=int(S[2:4])
if 1<=S1<=12:
    if 1<=S2<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 1<=S2<=12:
    print('YYMM')
else:
    print('NA')

Submission status: Accepted

Solution code:
s = input()
A = int(s[:2])

B = int(s[2:])

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

Submission status: Accepted

Solution code:
S = input()
a = [int(S[:2]), int(S[2:])]
b = [1<=c and c<=12 for c in a]

if b[0] and b[1]:
    print('AMBIGUOUS')
if b[0] and not b[1]:
    print('MMYY')
if not b[0] and b[1]:
    print('YYMM')
if not b[0] and not b[1]:
    print('NA')

Submission status: Accepted

Solution code:
s=input()
n1=int(s[0:2])
n2=int(s[2:4])
if 0<n1<13:
    if 0<n2<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 0<n2<13:
    print("YYMM")
else:
    print("NA")

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 126
# https://atcoder.jp/contests/abc126
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    a = int(S[:2])
    b = int(S[2:])
    ma = 1 <= a and a <= 12
    mb = 1 <= b and b <= 12
    if ma and mb:
        print('AMBIGUOUS')
    elif ma:
        print('MMYY')
    elif mb:
        print('YYMM')
    else:
        print('NA')

main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    s = input()
    f, t = s[:2], s[2:]
    YYMM = 0 <= int(f) <= 99 and 1 <= int(t) <= 12
    MMYY = 0 <= int(t) <= 99 and 1 <= int(f) <= 12
    if YYMM and MMYY:
        print('AMBIGUOUS')
    elif YYMM:
        print('YYMM')
    elif MMYY:
        print('MMYY')
    else:
        print('NA')

if __name__=="__main__":
    solve()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
S = input()

x1 = int(S[0:2])
x2 = int(S[2:4])

if 1 <= x1 <= 12:
    month1 = True
else:
    month1 = False

if 1 <= x2 <= 12:
    month2 = True
else:
    month2 = False

if month1 and month2:
    out = "AMBIGUOUS"
elif month1 and (not month2):
    out = "MMYY"
elif (not month1) and month2:
    out = "YYMM"
else:
    out = "NA"

print(out)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n = list(input())

a = n[0:2]

b = n[2:]
a = int("".join(a))
b = int("".join(b))

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

Submission status: Accepted

Solution code:
line = input()

MM_set = set([i+1 for i in range(12)])

first = int(line[:2])
second = int (line[2:])
if first in MM_set and second in MM_set:
  print("AMBIGUOUS")
elif first in MM_set and second not in MM_set:
  print("MMYY")
elif not first in MM_set and second in MM_set:
  print("YYMM")
else:
  print("NA")

Submission status: Accepted

Solution code:
S = input()

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    s = input()
    f = int(s[:2])
    l = int(s[2:])

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:

S=input()

if S[0]=="0":
    a=int(S[1])
else:
    a=int(S[:2])
if S[2]=="0":
    b=int(S[3])
else:
    b=int(S[2:])

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

Submission status: Accepted

Solution code:
s = input()
upper = int(s[0:2])
lower = int(s[2:4])

isYYMM = False
isMMYY = False
if 1 <= lower and lower <= 12  : 
    isYYMM = True
if 1 <= upper and upper <= 12 : 
    isMMYY = True

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

Submission status: Accepted

Solution code:
S=input()
x=int(S[:2])
y=int(S[2:])
#print(x,y)
a1=0
a2=0
if 0<=x<=99 and 1<=y<=12:
    a1=1
if 1<=x<=12 and 0<=y<=99:
    a2=1
if a1==1 and a2==1:
    print('AMBIGUOUS')
elif a1==1:
    print('YYMM')
elif a2==1:
    print('MMYY')
else:
    print('NA')

Submission status: Accepted

Solution code:
months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
input_line = input()
if (''.join(input_line[:2]) in months) and (''.join(input_line[2:]) in months):
    print('AMBIGUOUS')
elif ''.join(input_line[:2]) in months:
    print('MMYY')
elif ''.join(input_line[2:]) in months:
    print('YYMM')
else:
    print('NA')

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

A = int(S[0]) * 10 + int(S[1])
B = int(S[2]) * 10 + int(S[3])

if A > 0 and A <= 12:
    res_A = True
else:
    res_A = False

if B > 0 and B <= 12:
    res_B = True
else:
    res_B = False

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

Submission status: Accepted

Solution code:
S = input()

op = ["YYMM","MMYY","AMBIGUOUS","NA"]
a = int(S[0] + S[1])
b = int(S[2] + S[3])

if 1 <= a <= 12 and 1 <= b <= 12:
    print(op[2])
elif 1 <= a <= 12:
    print(op[1])
elif 1 <= b <= 12:
    print(op[0])
else:
    print(op[3])

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

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

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

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

############

S = input()

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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


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

Submission status: Accepted

Solution code:
S = input()

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


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

Submission status: Accepted

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

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

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

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Accepted

Solution code:
s = str(input())

is_yymm = False
is_mmyy = False

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

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

Submission status: Accepted

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

Submission status: Accepted

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


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

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

Submission status: Accepted

Solution code:
S = input()

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3

#import numpy as np
#import scipy, scipy.special

# Python 3 modules: https://docs.python.org/3/library/

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
# Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
# Before Python 3.5
from fractions import gcd

inf = float('inf')

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

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

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

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

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

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

################################################################################


S = int(input())

p = S // 100
q = S % 100

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

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

Submission status: Accepted

Solution code:
S = input()

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

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

Submission status: Accepted

Solution code:
am = 'AMBIGUOUS'
ym = 'YYMM'
my = 'MMYY'
na = 'NA'

s = input()

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

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

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

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

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

Submission status: Accepted

Solution code:
s = input()

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

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

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()

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

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    s = input().rstrip()



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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

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

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

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


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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:

s = input()

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

#print((pre,post))


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


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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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

S = input()

a = 0  # 先頭 MM
b = 0  # うしろ MM
c = 0  # 先頭 YY
d = 0  # うしろ YY

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

Submission status: Accepted

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

# n = int(input())
# a, b = map(int, input().split())
# 


amb = "AMBIGUOUS"
s = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

YYMM = []
MMYY = []

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

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

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

Submission status: Accepted

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

str = input()

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

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

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