peterverebics/CodeNet_Python_118 huggingface dataset:
N,Y=map(int,input().split())
for x in range(N+1):
    for y in range(N+1):
        z=N-x-y
        if z>=0 and 10000*x+5000*y+1000*z==Y:
            print(x,y,z)
            exit()

print(-1,-1,-1,sep=" ")
n, y = [int(i) for i in input().split()]
a, b, c, f = 0, 0, 0, 0

for i in range(n+1):
  for j in range(n+1):
    k = (y - 10000*i - 5000*j)/1000
    if k == n-i-j and k>=0:
      a, b, c = i, j, k
      f += 1
      break
      
if f == 0:
  print(-1,-1,-1)
else:
  print(int(a), int(b), int(c))
N,Y=map(int,input().split())
# x+y+z=N
# 10000x+5000y+1000z=Y
# となるような正整数(x,y,z)はあるか？
ans=[-1,-1,-1]
for x in range(N+1):
  for y in range(N-x+1):
    z=N-x-y
    if 10000*x+5000*y+1000*z==Y:
      ans=[x,y,z]
print(ans[0],ans[1],ans[2])
n,y=map(int,input().split())
Y=y//1000
a,b,c=0,0,0
for i in range(Y//10+1):
    rest=n-i
    for j in range(rest+1):
        k=rest-j
        if 10*i+5*j+k==Y:
            print(i,j,k)
            exit()
            
print('-1 '*3)
n, y = list(map(int, input().split()))

for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if k>=0 and y == i*10000+j*5000+k*1000:
            print(i, j, k)
            exit()
print(-1, -1, -1)
n, d = map(int, input().split())
ans = [-1]*3
for x in range(n+1):
    for y in range(n-x+1):
        zd = d - 10000*x - 5000*y
        if zd//1000 == n-x-y:
            ans[0] = x
            ans[1] = y
            ans[2] = zd//1000
            break
print(*ans)
def main():
    n, sum = list(map(int,input().split()))
    x_max = sum // 10000
    for x in reversed(range(0, x_max + 1)):
        for y in range(n - x + 1):
            z = n - x - y
            if 10000 * x + 5000 * y + 1000 * z == sum:
                    print(x, y, z)
                    return 0
    print('-1 -1 -1')
    return 0

main()
n, sum = map(int, input().split())
for x in range(n + 1):
    for y in range(n - x + 1):
        if x * 10000 + y * 5000 + (n-x-y) * 1000 == sum:
            print(x, y, n-x-y)
            exit()

print(-1, -1, -1)
def solve(N, Y):
    for a in range(N + 1):
        for b in range(N + 1 - a):
            c = N - (a + b)
            if a * 10000 + b * 5000 + c * 1000 == Y:
                return a, b, c
    return -1, -1, -1


N, Y = [int(n) for n in input().split()]
print(*solve(N, Y))
n , a = map(int, input().split())
num = 5000*n
ans = [0, n, 0]

def find(num):
    for _ in range(n+1):
        if num < a:
            ans[0] += 1
            ans[1] -= 1
            num += 5000
        elif num > a:
            ans[1] -= 1
            ans[2] += 1
            num -= 4000
        elif num == a:
            return ' '.join(map(str, ans))
    return '-1 -1 -1'

print(find(num))
N,Y=map(int,input().split())
for i in range(N+1):
    for m in range(N+1-i):
        y=N-i-m
        if Y==i*10000+m*5000+y*1000:
            print(i,m,y)
            exit()
print(-1,-1,-1)
def main():
 n,y = map(int,input().split())
 flag = 0
 for i in range(n + 1):
     for j in range(n - i + 1):
         if flag == 0 and  i * 10000 + j * 5000 + 1000 * (n - i - j) == y:
             flag = 1
             print(i,j,n - i - j)
 if flag == 0:
     print('-1 -1 -1')
main()
N,Y= map(int,input().split())

for a in range(N+1):
  for b in range(N-a+1):
    c = N-a-b
    if (10000*a+5000*b+1000*c ==Y):
      print('{} {} {}'.format(a,b,c))
      exit()
print('-1 -1 -1')
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        c=n-i-j
        if y==i*10000+j*5000+c*1000:
            print(i,j,c)
            exit()



print(-1,-1,-1)
N, Y = [int(x) for x in input().split()]

c10000 = -1
c5000 = -1
c1000 = -1

for a in range(N + 1):
    for b in range(N - a + 1):
        c = N - a - b
        total = 10000 * a + 5000 * b + 1000 * c
        if total == Y:
            c10000 = a
            c5000 = b
            c1000 = c
            break

print(str(c10000) + ' ' + str(c5000) + ' ' + str(c1000))
N, Y = map(int, input().split())
Yen = Y/1000

for i in range(N+1):
    for j in range(N+1-i):
        if i*10 + j*5 + (N-i-j) == Yen:
            print(i, j, N-i-j)
            exit()
print('-1 -1 -1')
n, y = map(int,input().split())
 
for i in range(0,n+1):
  for j in range(0, n-i+1):
    if y == 10000*i + 5000*j + 1000*(n-i-j):
      print("{0} {1} {2}".format(i, j, n-i-j))
      exit()
print("-1 -1 -1")
n,y=map(int,input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j)==y:
            print(i,j,n-i-j)
            exit()

print("-1 -1 -1")
[N, Y] = list(map(int, input().split()))
flag = False
for i in range(0, N+1):
  if 10000*i > Y:
    break
  for j in range(0, N+1-i):
    k = N-i-j
    total = 10000*i + 5000*j + 1000*k
    if total == Y:
      print("{} {} {}".format(i, j, k))
      flag = True
      break
  if flag:
    break

if flag == False:
  print("-1 -1 -1")
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N+1):
        k = N - i - j
        if k < 0:
            break
        if 10000 * i + 5000 * j + 1000 * k == Y:
            print(i, j, k)
            exit()
print(-1, -1, -1)
import sys
N,Y = map(int,input().split())

for i in range(N+1):

    for j in range(N-i+1):

        k = N - i - j

        if i * 10000 + j * 5000 + k * 1000 == Y:
            print (i,j,k)
            sys.exit()

print (-1,-1,-1)
N, Y = map(int, input().split())

for i in range(0, N+1, 1):
  isFinish = False
  for j in range(0, N+1-i, 1):
    sen = 1000 * i
    gosen = 5000 * j
    man = 10000 * (N - i - j)
    
    if sen + gosen + man == Y:
      print(N - i - j, j, i)
      isFinish = True
      break
  
  if isFinish:
    break
else:
  print(-1, -1, -1)
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i+5000*j+1000*(n-i-j)==y:
            print(i,j,n-i-j)
            exit()
print(-1,-1,-1)
n,yen=map(int,input().split())
yen//=1000
for x in range(n+1):
  for y in range(n-x+1):
    z=n-x-y
    cur_yen=x*10+y*5+z*1
    if cur_yen == yen:
      print(x,y,z)
      exit()
print(-1,-1,-1)
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        k10=i*10000
        k5=j*5000
        k1=(n-i-j)*1000
        if k10+k5+k1==y:
            print(i,j,n-i-j)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)
N, Y = map(int, input().split())
result = [-1, -1, -1]
# a = 0, 1, ..., N
for a in range(0, N + 1):
    # b = 0, 1, ..., N-a
    for b in range(0, N - a + 1):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            result = [a, b, c]
print(*result)
n,Y=map(int,input().split())
Y//=1000

ans=False
for x in range(n+1):
    for y in range(n+1):
        if Y-10*x-5*y==n-x-y and (n-x-y)>=0:
            ans=True
            break
    if ans==True:
        break

if ans is True:
    print(x,y,n-x-y)
else:
    print(-1,-1,-1)
N, Y = map(int, input().split())

resx, resy, resz = (-1, -1, -1)
xmax = min(N, Y//10000)
for x in range(xmax+1):
    for y in range(N-x+1):
        z = N - x - y
        total = 10000*x + 5000*y + 1000*z

        if total == Y:
            resx, resy, resz = (x, y, z)
            break
        else:
            continue

print(resx, resy, resz)
N, Y = map(int, input().split())

x, y, z = -1, -1, -1

for a in range(N+1):
    for b in range(N+1-a):
        if 10000*a + 5000*b + 1000*(N-a-b) == Y:
            x, y, z = a, b, N-a-b
        
print("{} {} {}".format(x,y,z))
def solve():
    n, y = map(int, input().split())
    r = range(n+1)

    ans = "-1 -1 -1"
    for i in r:
        for j in r:
            k = (y-(10000*i+5000*j))//1000
            if k >= 0 and 10000*i+5000*j+1000*k == y and i+j+k == n:
                ans = "{} {} {}".format(i, j, k)
                print(ans)
                return

    print(ans)


if __name__ == "__main__":
    solve()
N,Y = map(int,input().split())

for x in range(N+1):
    for y in range(N+1-x):
        p = x*10000 + y*5000
        if p > Y: break
        rem = Y - p
        z = rem//1000
        if x+y+z == N:
            print(x,y,z)
            exit()
print(-1,-1,-1)
N,Y=map(int,input().split())
A=[]
for i in range(Y//10000+1):
    for j in range((Y-i*10000)//5000+1):
        c1=(Y-10000*i-5000*j)/1000
        c2=N-i-j
        if c1==c2:
            A=[i,j,c1]
            break
        if c1!=c2:
            continue
if len(A)==0:
    print("-1 -1 -1")
else:
    A[2]=int(A[2])
    #intは整数、floatは少数
    print(str(A[0])+" "+str(A[1])+" "+str(A[2]))
import sys
n, y = map(int, input().split())
for a in range(n+1):
    for b in range(n+1-a):
        if 10000 * a + 5000 * b + 1000 * (n - a - b) == y:
            ans = [a, b, n - a - b]
            print(*ans, sep=" ")
            sys.exit()
    
print("-1 -1 -1")
#nは札枚数
n,y = map(int,input().split())

for i in range(n+1):
  for j in range(n-i+1):
    if i*10000 + j*5000 + (n-i-j)*1000 == y:
      print(i,j, n-i-j)
      exit()
print('-1 -1 -1')
n, y = list(map(int, input().split()))

for a in range(0, n+1):
    for b in range(0, n-a+1):
        c = n-(a+b)
        if (10000*a + 5000*b + 1000*c) == y:
            print(a, b, c)
            exit()

print(-1, -1, -1)
N, Y = map(int, input().split())

answer = '-1 -1 -1'
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y and z >= 0:
            answer = str(x) + ' ' + str(y) + ' ' + str(z) 
            break
print(answer)
n, total = [int(i) for i in input().split()]

for a in range(n+1):
  for b in range(n+1-a):
    c = n-a-b
    if c >= 0:
      if 10000*a + 5000*b + 1000*c == total:
        print('{} {} {}'.format(a, b, c))
        exit()
print('-1 -1 -1')
n, y = map(int, input().split())
for a in range(n+1):
    for b in range(n+1):
        c = n - (a+b)
        if a*10000 + b*5000 + c*1000 == y and a+b+c == n and c >= 0:
            print(a, b, c)
            exit()
print('-1 -1 -1')
x,y=map(int,input().split())
a1=-1
b1=-1
c1=-1
for a in range(0,x+1):
    for b in range(0,x+1-a):
        c=x-a-b
        if 10000*a+5000*b+1000*c==y:
            a1=a
            b1=b
            c1=c
print(a1,b1,c1)
n, y = map(int, input().split())
x = 0
for i in range(n + 1):
  for j in range(n + 1 - i):
    if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
      print(i, j, (n - i - j))
      x = 1
      break
  if x == 1:
    break
else:
  print(-1, -1, -1)
a,b=map(int,input().split())
c=-1
d=-1
e=-1
x=b//10000
for i in range(0,x+1,1):
  y=(b-10000*i)//5000
  for j in range(0,y+1,1):
    k=(b-10000*i-5000*j)//1000
    if i+j+k==a:
      c=i
      d=j
      e=k
print(c,d,e)
n, y = map(int, input().split())
for senyen in range(n + 1):
    for gosenyen in range(n + 1 - senyen):
        manyen = n - senyen - gosenyen
        if senyen * 1000 + gosenyen * 5000 + manyen * 10000 == y:
            print(manyen, gosenyen, senyen)
            exit(0)
print("-1 -1 -1")
N, Y = map(int, input().split())
x, y, z = -1, -1, -1

for i in range(N+1):
    for j in range(N-i+1):
            k = N - i - j
            if 10000*i+5000*j+1000*k == Y:
                x, y, z = i, j, k
                break
print(x, y, z)
n,y = map(int, input().split())

a = -1
b = -1
c = -1
n1 = min(y // 10000, n)
n2 = min(y // 5000, n)
for i in range(n1+1):
    for j in range(n2+1-i):
        money = 10000 * i + 5000 * j + 1000 * (n - i - j)
        if y == money:
            a = i
            b = j
            c = n - i - j
            break;


print(str(a)+" ",str(b)+" ",str(c))
n, y = map(int,input().split())
y = y//1000
for i in range(n+1):
    for j in range (n+1-i):
        k = n - i - j
        if 10*i + 5* j + 1 * k == y:
            print(str(i) +' '+str(j)+' '+str(k))
            exit()
print('-1 -1 -1')
import sys
n,Y = map(int,input().split())
for x in range(n+1):
    for y in range(n-x+1):
        z = n-(x+y)
        if z >= 0 and 10000*x+5000*y+1000*z == Y:
            print(x,y,z)
            sys.exit()
print(-1,-1,-1)
n, y = map(int, input().split())

a, b, c = -1, -1, -1

for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        if 10000*i + 5000*j + 1000*k == y:
            a, b, c = i, j, k

print(a, b, c)
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N+1-x):
        z = N - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()

print("-1 -1 -1")
N, Y = map(int, input().split())

for x in range(N + 1):
    for y in range(N + 1 - x):
        z = N - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()

print("-1 -1 -1")
li=list(map(int,input().split()))
n=li[0]
y=li[1]

a,b,c=-1,-1,-1

for i in range(n+1):
    for j in range(n-i+1):
        if y==10000*i+5000*j+1000*(n-i-j):
            a=i
            b=j
            c=n-i-j
            break
print(a,b,c)
n,y = map(int, input().split())
ans = -1, -1, -1
for i in range(n+1):
    for j in range(n-i+1):
        if i*10000+j*5000+(n-i-j)*1000==y:
            ans = i, j, (n-i-j)
print(*ans)
N, Y =map(int, input().split())
c = 0
for n in range(N+1):
    if c == 1:
        break
    for m in range(N-n+1):
            l = N -n - m
            if Y ==( n*10000 + m *5000 + l *1000) and (n + m + l) == N:
                print(n , m , l)
                c = 1
                break
if c != 1:
    print(-1 , -1 , -1)
def main():
  N, Y = list(map(int, input().split()))
  for i in range(N+1):
    for j in range(N+1-i):
      k = N-i-j
      if Y == (10000*i + 5000*j + 1000*k):
        print(i, j, k)
        return
  print(-1, -1, -1)


if(__name__ == '__main__'):
  main()
# -*- coding: utf-8 -*-
import sys
a=10000
b=5000
c=1000

def check(y, i,j,k):
    if(y == i * a + j * b + k * c):
        print(i,j,k)
        sys.exit(0)

n, y = map(int, input().split())

for i in range(n,-1,-1):
    for j in range(n-i,-1,-1):
        k = n-i-j
        check(y,i,j,k)

print(-1,-1,-1)
n, y = map(int, input().split())
for m10 in range(n+1):
    for m5 in range(n-m10 +1):
        m1 = n - m10 - m5
        if m10 *10000 + m5 * 5000 + m1 * 1000 == y:
            print(m10, m5, m1)
            exit(0)
print("-1 -1 -1")
import sys
N,Y = map(int,input().split())
for x in range(0,N+1):
    for y in range(0,N+1-x):
        if 10000*x+5000*y + (N-x-y)* 1000 == Y:
            print('%d %d %d' % (x,y,N-x-y))
            sys.exit(0)
print('-1 -1 -1')
n,m = map(int,input().split())
for x in range(n+1):
  for y in range(n+1):
    z = n - x - y
    if (10000*x + 5000*y + 1000*z == m and x + y + z == n and 0 <= z <=n):
        print(x,y,z)
        exit()
print('-1 -1 -1')
N,Y=map(int,input().split())
Y//=1000
for i in range(N+1):
    for j in range(N-i+1):
        if i*10+j*5+(N-i-j)==Y:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1)
N, Y = map(int, input().split())
 
ans10000, ans5000, ans1000 = -1, -1, -1
for i in range(0, N+1):
    for j in range(0, (N+1)-i):
        k = N - (i + j)
        if k >= 0:
            o = 10000*i + 5000*j + 1000*k
            if o == Y:
                ans10000 = i
                ans5000 = j
                ans1000 = k
                
print(ans10000, ans5000, ans1000)
N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if Y == 10000 * x + 5000 * y + 1000 * z:
            print(x, y, z)
            exit()
print("-1 -1 -1")
N,Y = map(int,input().split())
for x in range(N+1):
    for y in range(N - x + 1):
        if 10000*x+5000*y+1000*(N - x - y) == Y:
            print(x,y,N-x-y)
            exit()
print("-1 -1 -1")
import sys
n,y=map(int,input().split())
t=True
for i in range(n+1):
    for j in range(n+1):
        if ((10000*i+5000*j+1000*(n-i-j))==y) & (i+j<=n):
            t=False
            print(i, j, n-i-j)
            sys.exit(0) 
if t:
    print("-1 -1 -1")
n, y = map(int, input().split())

for i in range(n + 1):
  for j in range(n - i + 1):
    if y == 10000 * i + 5000 * j + 1000 * (n - i - j):
      print(i, j, n - i - j)
      exit()

print("-1 -1 -1")
n,y=[int(i) for i in input().split()]

#aの上限
a_num=y//10000
#bの上限
b_num=y//5000

com=[]
for a in range(a_num+1):
    for b in range(b_num+1):
        if 10000*a+5000*b+1000*(n-(a+b))==y and 0<=n-(a+b):
            com.append([a,b,n-(a+b)])
            break
if com==[]:
    print("-1 -1 -1")
else:
    print(com[0][0],com[0][1],com[0][2])
N,Y=map(int,input().split())
x=-1
y=-1
z=-1
for i in range(N+1):
    for j in range(N-i+1):   
         if  i*10000+j*5000+(N-i-j)*1000==Y:
                x=i
                y=j
                z=N-i-j
           

print(x,y,z)
N, Y = map(int, input().split())
Y //= 1000
for a in range(Y//10 + 1):
    for b in range((Y - 10 * a) // 5 + 1):
        c = (Y - 10 * a - 5 * b)
        if a + b + c == N:
            print(a, b, c)
            exit()
print(-1, -1, -1)
import sys

N, Y = list(map(int, input().split()))
x, y, z = -1, -1, -1
money = 0
for i in range(N + 1):
    for j in range(N - i + 1):
        if Y == i * 10000 + j * 5000 + (N - i - j) * 1000:
            print(i, j, N - i - j)
            sys.exit()

print(x, y, z)
N,Y = map(int,input().split())
Y //= 1000
for i in range(N+1):
    for j in range(N+1-i):
        if 10*i + 5*j + 1*(N-i-j) == Y:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1)
N, Y = list(map(int, input().split()))

ans = 0
for y in range(N +1):
    for w in range(N +1):
        if y*10000+w*5000+(N-y-w)*1000 == Y and N-y-w >= 0:
            ans = str(y)+" "+str(w)+" "+str(N-y-w)

if ans == 0:
    print(-1, -1, -1)
else:
    print(ans)
n, y = map(int, input().split())

for i in range(n, -1, -1):
    for j in range(n-i, -1, -1):
        if i *10000 + j * 5000 + (n-i-j) * 1000 == y:
            print(str(i) + ' ' + str(j) + ' ' + str(n-i-j))
            exit(0)

print("-1 -1 -1")
n, y = map(int, input().split())
y /= 1000 #10円札,5円札,1円札

for i in range(n+1): # i = 10円札の枚数
    for j in range(n-i+1): # j = 5円札の枚数
        k = n - i - j
        if 10*i + 5*j + k == y:
            print(i, j, k)
            exit()

print('-1 -1 -1')
N, Y = map(int, input().split())

for n_10000 in range(min(N+1, Y//10000+1)):
    for n_5000 in range(min(N-n_10000+1, (Y-n_10000*10000)//5000+1)):
        n_1000 = N - n_10000 - n_5000
        if n_10000 * 10000 + n_5000 * 5000 + n_1000 * 1000 == Y:
            print(n_10000, n_5000, n_1000)
            exit()

print('-1 -1 -1')
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i*10000 + j*5000 + (n - i - j)*1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")
N, Y = map(int, input().split())
for i in range(min(Y//10000, N)+1):
    for j in range(min((Y-(10000*i))//5000, N-i)+1):
        zankin = Y - (10000*i) - (5000*j)
        if i + j + zankin //1000 == N:
            print(i, j, zankin//1000)
            exit()
print(-1, -1, -1)
N, Y = map(int, input().split())
a, b, c = -1, -1, -1
for i in range(0, int(Y / 10000) + 1):
  for j in range(0, N - i + 1):
    if 10000*i + 5000*j + 1000*(N - i - j) == Y:
      a, b, c = i, j, N - i - j
      break
  else:
    continue
  break
print(a, b, c)
n,y=map(int,input().split())
for i in range(2001):
	for j in range(2001):
		if (y-(10000*i+5000*j))//1000==n-i-j and n-i-j>=0:
			print(i,j,n-i-j)
			exit()
print(-1,-1,-1)
n,y=map(int,input().split())
y //=1000
for i in range(n+1):
    for j in range(n-i+1):
        if n -(i+j) < 0:
            break
        if 9*i+4*j+n == y:
            print(i,j,n-(i+j))
            exit()
print('-1','-1','-1')
N = input().split()
N = [int(i) for i in N]

judge = False
for i in range(0, N[0]+1):
    for j in range(0, N[0]+1-i):
        k = N[0]-i-j
        if(10000*i + 5000*j + 1000*k == N[1]):
            judge = True
            break
    else:
        continue
    break

if(judge):
    print(i, j, k)
else:
    print(-1, -1, -1)
n,y=list(map(int,input().split()))

res10000=-1
res5000=-1
res1000=-1
for i in range(n+1):
    for j in range(n-i+1):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y:
          res10000,res5000,res1000=i,j,k
          break

print('{} {} {}'.format(res10000,res5000,res1000))
# solution

import io
nim, mike = map(int, input().split())
for i in range(nim + 1):
    for j in range(nim - i + 1):
        if i * 10000 + j * 5000 + (nim - i - j) * 1000 == mike:
            print(i, j, nim - i - j)
            exit()
print("-1 -1 -1")
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,Y = map(int, input().split())

a = b = c = -1
for i in range((Y//10000)+1):
    for j in range((Y-10000*i)//5000+1):
        s = 10000*i + 5000*j + 1000*(N-i-j)
        if s == Y:
            a,b,c = i,j,N-i-j
            
print(a,b,c)
n,y=map(int,input().split())
y//=1000
for ten in range(n+1):
  for five in range(n-ten+1):
    one=n-ten-five
    if ten*10+five*5+one==y:
      print(ten,five,one)
      exit(0)
print(-1,-1,-1)
n, y = map(int,input().split())

def otoshidama():
    for i in range(0,n+1):
        for j in range(0,n+1-i):
            k = n-i-j
            if 10000*i + 5000*j + 1000*k == y:
                return i,j,k
    return -1,-1,-1

 
a, b, c = otoshidama()
print(a,b,c)
N, Y = map(int, input().split())
ans = [-1,-1,-1]
for x in range(0,N+1):
    for y in range(0,N-x+1):
        z = N - x - y
        if x*10000 + y*5000 + z*1000 == Y:
            ans[0] = x
            ans[1] = y
            ans[2] = z
print(ans[0],ans[1],ans[2])
n,y = map(int, input().split())
for i in range(n+1):
    for j in range(n+1-i):
        k = n - i - j
        if 10000*k + 5000*j + 1000*i == y:
                print(k, j, i)
                exit()
print(-1,-1,-1)
N, Y = map(int, input().split())

for x in range(N+1):
  for y in range(N+1):
    z = N - x - y
    if Y == x *10000 + y*5000 + z*1000 and z >= 0:
      print(x, y, z)
      exit()
print(-1, -1, -1)
def main2():
    t = (input().split(' '))
    t = [int(v) for v in t]
    if t[0] * 10000 < t[1]:
        print('-1 -1 -1')
        exit(0)
    for i in range(t[0] + 1):
        for j in range((t[0] + 1) - i):
            if (10000 * i) + (5000 * j) + ((t[0] - i - j) * 1000) == t[1]:
                print(i, j, (t[0] - i - j))
                exit(0)

    print('-1 -1 -1')


if __name__ == '__main__':
    main2()
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        if 0<=k<=2000 and 10000*i + 5000*j + 1000*k == y :
            print(i, j, k)
            exit()
print(-1,-1,-1)
import sys
N,Y=map(int,input().split())
Y=Y//1000
if N>Y or N*10<Y:
  print(-1,-1,-1)
  sys.exit()
for i in range(N+1):
  for j in range(N-i+1):
    k=N-i-j
    if i+5*j+10*k==Y:
      print(k,j,i)
      sys.exit()
print(-1,-1,-1)
N, Y = map(int,input().split())
answer = -1,-1,-1
for x in range(N+1):
	for y in range(N-x+1):
		z = N-x-y
		if 10000*x+5000*y+1000*z == Y:
			answer = x,y,z
			break
		else:
			continue
		break
print(*answer)
n, y = map(int, input().split())

total = 0
ans = list()
for a in range(0, n+1, 1):
  for b in range(0, n+1, 1):
    if a + b <= n:
      c = n - (a+b)
      total = a*10000 + b*5000 + c*1000
      if total == y:
        lists = [a,b,c]
        ans.append(lists)
    else:
      break

if ans == []:
  answer = ['-1', '-1', '-1']
  answer = ' '.join(answer)
else:
  answer = [str(i) for i in ans[0]]
  answer = ' '.join(answer)

print(answer)
N, Y = [int(_) for _ in input().split()]
x = 0
y = 0
z = 0
isOK = False


def sumMoney(x, y, z):
    return x*10000+y*5000+z*1000


for z in range(N+1):
    for y in range(N-z+1):
        x = N-z-y
        if sumMoney(x, y, z) == Y:
            print(x, y, z)
            isOK = True
            break
    if isOK:
        break


if not isOK:
    print(-1, -1, -1)
N, Y = map(int,input().split())

ans = -1,-1,-1
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z == Y:
            ans = x,y,z
            break
        else:
            continue
        break
print(*ans)
N,Y = map(int,input().split())

break_loop=False
for a in range(N+1):
    for b in range(N+1-a):
        c = N-a-b
        if 10000*a + 5000*b + 1000*c == Y:
            print(a,b,c)
            break_loop=True
            break
    if break_loop:
        break
    else:
        continue
else:
    print(-1,-1,-1)