import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

#https://atcoder.jp/contests/abc126/tasks/abc126_b

def is_mm(s):
	return int(s) >= 1 and int(s) <= 12

def is_yy(s):
	return True

def main():
	#a = int(input())
	#b , c = IN()
	s = input()
	is_mmxx=is_mm(s[:2])
	is_yyxx=is_yy(s[:2])
	is_xxmm=is_mm(s[2:])
	is_xxyy=is_yy(s[2:])
	ra = 'AMBIGUOUS'
	rb = 'NA'
	rc = 'YYMM'
	rd = 'MMYY'
	
	if is_mmxx and is_xxyy and is_xxmm and is_yyxx:
		return ra
	elif is_mmxx and is_xxyy:
		return rd
	elif is_yyxx and is_xxmm:
		return rc
	else:
		return rb
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret) import sys sys input_methods=['clipboard','file','key'] input_methods ['clipboard','file','key'] 'clipboard' 'file' 'key' using_method=0 using_method 0 input_method=input_methods[using_method] input_method input_methods[using_method] input_methods using_method IN=lambda : map(int, input().split()) IN lambda : map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split mod=1000000007 mod 1000000007 def is_mm(s):
	return int(s) >= 1 and int(s) <= 12 is_mm return int(s) >= 1 and int(s) <= 12 int(s) >= 1 and int(s) <= 12 int(s) >= 1 int(s) int s 1 int(s) <= 12 int(s) int s 12 s s def is_yy(s):
	return True is_yy return True True s s def main():
	#a = int(input())
	#b , c = IN()
	s = input()
	is_mmxx=is_mm(s[:2])
	is_yyxx=is_yy(s[:2])
	is_xxmm=is_mm(s[2:])
	is_xxyy=is_yy(s[2:])
	ra = 'AMBIGUOUS'
	rb = 'NA'
	rc = 'YYMM'
	rd = 'MMYY'
	
	if is_mmxx and is_xxyy and is_xxmm and is_yyxx:
		return ra
	elif is_mmxx and is_xxyy:
		return rd
	elif is_yyxx and is_xxmm:
		return rc
	else:
		return rb
	
#+++++ main s = input() s input() input is_mmxx=is_mm(s[:2]) is_mmxx is_mm(s[:2]) is_mm s[:2] s :2 2 is_yyxx=is_yy(s[:2]) is_yyxx is_yy(s[:2]) is_yy s[:2] s :2 2 is_xxmm=is_mm(s[2:]) is_xxmm is_mm(s[2:]) is_mm s[2:] s 2: 2 is_xxyy=is_yy(s[2:]) is_xxyy is_yy(s[2:]) is_yy s[2:] s 2: 2 ra = 'AMBIGUOUS' ra 'AMBIGUOUS' rb = 'NA' rb 'NA' rc = 'YYMM' rc 'YYMM' rd = 'MMYY' rd 'MMYY' if is_mmxx and is_xxyy and is_xxmm and is_yyxx:
		return ra
	elif is_mmxx and is_xxyy:
		return rd
	elif is_yyxx and is_xxmm:
		return rc
	else:
		return rb
	
#+++++ is_mmxx and is_xxyy and is_xxmm and is_yyxx is_mmxx and is_xxyy and is_xxmm is_mmxx and is_xxyy is_mmxx is_xxyy is_xxmm is_yyxx return ra ra elif is_mmxx and is_xxyy:
		return rd
	 is_mmxx and is_xxyy is_mmxx is_xxyy return rd rd elif is_yyxx and is_xxmm:
		return rc
	 is_yyxx and is_xxmm is_yyxx is_xxmm return rc rc return rb rb isTest=False isTest False def pa(v):
	if isTest:
		print(v)
		 pa if isTest:
		print(v)
		 isTest print(v) print v v v def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l input_clipboard import clipboard clipboard input_text=clipboard.get() input_text clipboard.get() clipboard.get clipboard get input_l=input_text.splitlines() input_l input_text.splitlines() input_text.splitlines input_text splitlines for l in input_l:
		yield l l input_l yield l l if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret) __name__ == "__main__" __name__ "__main__" if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	 sys.platform =='ios' sys.platform sys platform 'ios' if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		 input_method==input_methods[0] input_method input_methods[0] input_methods 0 ic=input_clipboard() ic input_clipboard() input_clipboard input = lambda : ic.__next__() input lambda : ic.__next__() ic.__next__() ic.__next__ ic __next__ elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		 input_method==input_methods[1] input_method input_methods[1] input_methods 1 sys.stdin=open('inputFile.txt') sys.stdin sys stdin open('inputFile.txt') open 'inputFile.txt' isTest=True isTest True ret = main() ret main() main if ret is not None:
		print(ret) ret is not None ret None print(ret) print ret def is_yy(s):
	return True def is_yy(s):
	return True is_yy ic=input_clipboard() input_clipboard() ic ret = main() main() ret input_methods=['clipboard','file','key'] ['clipboard','file','key'] input_methods def main():
	#a = int(input())
	#b , c = IN()
	s = input()
	is_mmxx=is_mm(s[:2])
	is_yyxx=is_yy(s[:2])
	is_xxmm=is_mm(s[2:])
	is_xxyy=is_yy(s[2:])
	ra = 'AMBIGUOUS'
	rb = 'NA'
	rc = 'YYMM'
	rd = 'MMYY'
	
	if is_mmxx and is_xxyy and is_xxmm and is_yyxx:
		return ra
	elif is_mmxx and is_xxyy:
		return rd
	elif is_yyxx and is_xxmm:
		return rc
	else:
		return rb
	
#+++++ def main():
	#a = int(input())
	#b , c = IN()
	s = input()
	is_mmxx=is_mm(s[:2])
	is_yyxx=is_yy(s[:2])
	is_xxmm=is_mm(s[2:])
	is_xxyy=is_yy(s[2:])
	ra = 'AMBIGUOUS'
	rb = 'NA'
	rc = 'YYMM'
	rd = 'MMYY'
	
	if is_mmxx and is_xxyy and is_xxmm and is_yyxx:
		return ra
	elif is_mmxx and is_xxyy:
		return rd
	elif is_yyxx and is_xxmm:
		return rc
	else:
		return rb
	
#+++++ main using_method=0 0 using_method isTest=True True isTest input_method=input_methods[using_method] input_methods[using_method] input_method def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l input_clipboard mod=1000000007 1000000007 mod def is_mm(s):
	return int(s) >= 1 and int(s) <= 12 def is_mm(s):
	return int(s) >= 1 and int(s) <= 12 is_mm IN=lambda : map(int, input().split()) lambda : map(int, input().split()) IN input = lambda : ic.__next__() lambda : ic.__next__() input isTest=False False isTest def pa(v):
	if isTest:
		print(v)
		 def pa(v):
	if isTest:
		print(v)
		 pa
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

#https://atcoder.jp/contests/abc126/tasks/abc126_b

def is_mm(s):
	return int(s) >= 1 and int(s) <= 12

def is_yy(s):
	return True

def main():
	#a = int(input())
	#b , c = IN()
	s = input()
	is_mmxx=is_mm(s[:2])
	is_yyxx=is_yy(s[:2])
	is_xxmm=is_mm(s[2:])
	is_xxyy=is_yy(s[2:])
	ra = 'AMBIGUOUS'
	rb = 'NA'
	rc = 'YYMM'
	rd = 'MMYY'
	
	if is_mmxx and is_xxyy and is_xxmm and is_yyxx:
		return ra
	elif is_mmxx and is_xxyy:
		return rd
	elif is_yyxx and is_xxmm:
		return rc
	else:
		return rb
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)