unittest
{
	assert( [ "9 45000" ].parse.expand.solve == "4 0 5" );
	assert( [ "20 196000" ].parse.expand.solve == "-1 -1 -1" );
//	assert( [ "1000 1234000" ].parse.expand.solve == "14 27 959" );		// 解が複数あるのでこれはtrueにならない場合がある
	assert( [ "1000 1234000" ].parse.expand.solve == "26 0 974" );
	assert( [ "2000 20000000" ].parse.expand.solve == "2000 0 0" );
}



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

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ny = input.front.split.to!( long[] );
	return tuple( ny[ 0 ], ny[ 1 ] );
}

auto solve( long n, long y )
{
	for( auto yen10000_n = n; 0 <= yen10000_n; yen10000_n-- )
	{
		auto yen10000_y = yen10000_n * 10000;
		if( y < yen10000_y ) continue;
		
		for( auto yen5000_n = n - yen10000_n; 0 <= yen5000_n; yen5000_n-- )
		{
			auto yen5000_y = yen5000_n * 5000;
			if( y < yen10000_y + yen5000_y ) continue;
			
			auto yen1000_n = n - yen10000_n - yen5000_n;
			auto yen1000_y = yen1000_n * 1000;
			
			if( y == yen10000_y + yen5000_y + yen1000_y )
			{
				return format( "%d %d %d", yen10000_n, yen5000_n, yen1000_n );
			}
		}
	}
	
	return "-1 -1 -1";
}
