unittest
{
	assert( [ "1905" ].parse.expand.solve == "YYMM" );
	assert( [ "0112" ].parse.expand.solve == "AMBIGUOUS" );
	assert( [ "1700" ].parse.expand.solve == "NA" );
	
	assert( [ "0519" ].parse.expand.solve == "MMYY" );		// 追加ケース
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	auto na = s[ 0 .. 2 ].to!long;
	auto nb = s[ 2 .. 4 ].to!long;
	if( 1 <= na && na <= 12 && 1 <= nb && nb <= 12 ) return "AMBIGUOUS";
	if( 1 <= na && na <= 12 ) return "MMYY";
	if( 1 <= nb && nb <= 12 ) return "YYMM";
	return "NA";
}
