program sample
    implicit none
    character(100)s1,s2,s3
    integer(8) :: i,j,m,n,y,a,b,c,x,z
    
  
    read(*,*) n,y
    a=y/10000
    x=mod(y,10000)
    if(n>y/1000)then
        write(*,*)'-1 -1 -1'
        stop
    end if
    
    if(x>=5000)then
        b=1
        c=x/1000-5
    else
        c=x/1000
    end if!ここで最小の枚数
  
    if(a+b+c>n)then
        write(*,*)'-1 -1 -1'
        stop
    end if

    if(2*a+b+c>=n)then
        z=n-a-b-c
        a=a-z
        b=b+2*z
        
    else
        x=mod(n,4)
        z=mod(2*a+b+c,4)
        x=mod(z+4-x,4)
        if(a-x<0)then
            write(*,*)'-1 -1 -1'
            stop
        end if
        b=b+2*(a-x)
        a=x
        x=(n-a-b-c)/4
        b=b-x
        if(b<0)then
            write(*,*)'-1 -1 -1'
            stop
        end if
        c=c+5*x

    end if
    write(s1,'(i4)')a
    write(s2,'(i4)')b
    write(s3,'(i4)')c
 
    write(*,fmt='(a,x,a)',advance='no')s1,s2
    write(*,fmt='(a)',advance='no')s3

    stop
end program sample
  

