peterverebics/CodeNet_Python_118 huggingface dataset:
def solve(n, y):

    a = 0
    ans = "-1 -1 -1"
    while a <= n :
        
        c = (y - 5000*(a+n)) // (-4000) if (y - 5000*(a+n)) % (-4000) == 0 else -1
        
        b = n - a - c
        if b >= 0 and c >= 0:
            ans = "{0} {1} {2}".format(a, b, c)
            break
        else:
            a += 1

    return ans

if __name__ == "__main__":
    n,y = [int(i) for i in input().split()]
    print(solve(n, y))
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")
import sys
n, price = map(int, input().split())
ans = [-1, -1, -1]
for x in range(n+1):
    for y in range(n+1):
        z = n - x - y
        if z < 0:
            continue
        if 10000 * x + 5000 * y + 1000 * z == price:
            ans = [x, y, z]
            print(*ans)
            sys.exit()
print(*ans)
a, b = map(int, input().split())
count = 0
for i in range(a+1):
  for j in range(a+1-i):
    s = (10000*i) + (5000*j) + (1000*(a-i-j))
    if s == b:
      print(i,j,(a-i-j))
      count += 1
      break
  else:
    continue
  break
  
if count == 0:
  print(-1,-1,-1)
N,Y = [int(x) for x in input().split()]
Y = Y // 1000
for y in range(N+1):
  if (Y - N - 4*y) % 9 != 0:
    continue
  x = int((Y - N - 4*y) / 9)
  z = N - y - x
  if 0 <= x and 0 <= z and x <= N and z <= N:
    print(x,y,z)
    exit()
print("-1 -1 -1")
import numpy as np

N, Y = map(int, input().split())
res = Y - 1000*N
b = -1
for a in range(N+1):
    cand = 9000*a + np.linspace(0, 4000*(N-a), N-a+1)
    if (cand == res).sum() > 0:
        b = np.where(cand==res)[0][0]
        c = N-a-b
        break
if b == -1:
    print(-1, -1, -1)
else:
    print(a, b, c)
N, Y = map(int, input().split())

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

for i in range(N+1):
    for j in range(N+1):
        if i+j <= N:
            if 10000*i + 5000*j + 1000*(max(N-i-j, 0)) == Y:
                x = i
                y = j
                z = N - (i+j)
                break

print(x, y, z)
N,Y = (int(x) for x in input().split())
y = Y // 1000
for i in range(N+1):
    for j in range(N+1-i):
        if 10*i + 5*j + (N-i-j) == y:
            print(i,j,N-i-j)
            break
    else:
        continue
    break
else:
    n = -1
    print(n,n,n)
N,Y = map(int,input().split())
res = 0
for i in range(N+1):
	for j in range(N+1-i):
		if 10000*i+5000*j+1000*(N-i-j) == Y:
			if res == 1:
				break
			print(i,j,N-i-j)
			res = 1
if res == 0:
	print(-1,-1,-1)
n, y = map(int, input().split())
t = 0
for i in range(n+1):
    if t == 1:
        break
    for j in range(n+1):
        if (i+j) <= n:

            if i * 1000 + j * 5000 + (n - i - j) * 10000 == y:
                print((n - i - j), j, i)
                t = 1
                break


if t == 0:
    print(-1, -1, -1)
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/12
# Filename: main 
# Author: acto_mini

def main():
    N, Y = map(int, input().split())
    print()

    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)
                exit()
    print("-1 -1 -1")
    return


if __name__ == '__main__':
    main()
N, Y = map(int, input().split())
ans1 = ["-1", "-1", "-1"]
for i in range(0, N+1):
    for j in range(0, N+1):
        if N-j>=0 and N-i-j >= 0:
            if Y == 10000*i+5000*j+1000*(N-i-j):
                ans1 = [str(i), str(j), str(N-i-j)]
print(" ".join(ans1))
n,y = map(int, input().split())
a = []
for i in range(0,n+1,1):
  for j in range(0,n+1,1):
    if 9000*i+4000*j == y-1000*n and n-i-j >= 0:
      a = [i,j,n-i-j]
if a == []:
  print(-1,-1,-1)
else:
  print(a[0],a[1],a[2])
n,y=map(int,input().split())
for i in range(n+1):
 for j in range(n-i+1):i*9+j*4+n==y/1e3<exit(print(i,j,n-i-j))
print(-1,-1,-1)
N,Y=map(int,input().split())
n=Y//10000

if n>N:
    print("-1 -1 -1")
    exit()

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

flag = False
for x in range(N+1):
    for y in range(N+1-x):
        z = N-x-y
        if x*10000 + y*5000 + z*1000 == Y:
            print(x,y,z, sep=' ')
            flag = True
            break
    if flag:
        break
if not flag:
    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 - x):
        z = N - x - y
        if 0 <= z <= N and 10000 * x + 5000 * y + 1000 * z == Y:
            answer = x, y, z
            break
    else:
        continue
    break
print(*answer)
N,Y=map(int,input().split())

flag=False

for i in range(N+1):
  for j in range(N+1):
    if(9000*i+4000*j==Y-1000*N):
      flag=True
      x=i
      y=j
      z=N-i-j
      
if(flag==True and z>=0):
  print(str(x)+" "+str(y)+" "+str(z))
else:
  print("-1 -1 -1")
n, y = map(int, input().split())
k = y - 1000*n
count = 0
for i in range(0, 2001):
    for j in range(0, 4001):
        if 9000*i + 4000*j == k and n-i-j >= 0:
            a = i
            b = j
            c = n - i - j
            count = 1
            break
        else:
            pass
if count == 1:
    print(a, b, c)
else:
    print("-1 -1 -1")
def main():  
  N, Y = map(int,input().split())
  Cash = [10000, 5000, 1000]
  for x in range(N+1):
    for y in range(N+1):
      Rem = Y - (10000*x + 5000*y)
      Rem = Rem//1000
      if Rem == (N - x - y) and Rem >=0:
        print(x, y, Rem)
        return 
  print(-1, -1, -1)
  return

main()
from sys import stdin
n,y = [int(x) for x in stdin.readline().rstrip().split()]
flag = False

for p in reversed(range(n+1)):
   if p * 10000 > y:
      continue
   else:
      for q in reversed(range(n-p+1)):
         if 10000*p + 5000*q + 1000*(n-p-q) == y:
            print(p,q,n-p-q)
            flag = True
            break
      if flag == True:
         break
   if flag == True:
      break
if flag == False:
   print(-1,-1,-1)
N, Y = map(int, input().split())
ansX = -1
ansY = -1
ansZ = -1
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:
            ansX = x
            ansY = y
            ansZ = z
            
print(ansX, ansY, ansZ)
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n-i+1):
    b=10000*i+5000*j+1000*(n-i-j)
    if y==b:
      print(i,j,n-i-j)
      exit()
print(-1,-1,-1)
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 i in range(N+1):
    for j in range(N+1):
        c = N - i - j
        if 0<= c <= 2000 and (10000*i + 5000*j + c*1000) == Y:
            print(i,j,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):
        x=n-i-j
        if 1000*i+5000*j+10000*x==y:
            print(x,j,i)
            exit()
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())
amari=y-1000*n

if amari < 0:
    print(-1,-1,-1)
    exit()

for k in range(0,n+1):
    if amari-4000*k >= 0 and (amari-4000*k)%5000 == 0:
        x=(amari-4000*k)//5000
        if k-x >= 0:
            y=k-x
            print(x,y,n-k)
            break
else:
    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)
N,Y=map(int,input().split())
a=-1
b=-1
c=-1
for i in range(0,N+1):
    for j in range(0,N-i+1):
        if 10000*i+5000*j+1000*(N-i-j) == Y:
                a=i
                b=j
                c=N-i-j
print(a,b,c)
n,y=map(int,input().split())
for i in range(n+1):
    y_=y-10000*i
    for j in range(n-i+1):
        y__=y_-5000*j
        if y__//1000==n-i-j:
            print(i,j,n-i-j)
            exit()
print(-1,-1,-1)
n, y = map(int, input().split())
x = 0
for i in range(n + 1):
    # if 10000*i > y:break
    for j in range(n - i + 1):
        # if 10000 * i + 5000 * j > y:
        #     break
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            print(i, j, n - i - j)
            x = 1
            break

    if x == 1:
        break

if x == 0:
    print(-1,-1,-1)
N, Y = map(int, input().split())
d = (Y // 1000) - N
flg = True
for i in range(N + 1):
  if (d - 9 * i) % 4 == 0 and d >= 9 * i:
    if (i + (d - 9 * i) // 4) <= N:
      print(i, (d - 9 * i) // 4, N - i - (d - 9 * i) // 4)
      flg = False
      break
if flg:
  print(-1, -1, -1)
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1-i):
        if i * 10000 + j * 5000 + (n-i-j) * 1000 == y:
            print(i, j, n-i-j)
            exit()
else:
    print(-1, -1, -1)
N, Y = map(int, input().split())
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:
            print(x, y, z)
            exit()
print(-1, -1, -1)
def resolve():
  n, y = map(int, input().split())
  for i in range(n + 1):
    for j in range(n + 1 - i):
      k = n - i - j
      if i * 10000 + j * 5000 + k * 1000 == y:
        print(i, j, k)
        return
  print(-1, -1, -1)
  return

if __name__ == "__main__":
  resolve()
#!/usr/bin/env python3
N, Y = map(int, input().split())
for i in range(0, N + 1):
    x = 4/5*i + Y/5000 - N
    y = -9/5*i - Y/5000 + 2*N
    z = i
    if (x.is_integer() & y.is_integer()):
        # print(0 <= x <= N, 0 <= y <= N)
        # print(int(x), int(y), z)
        if ((0 <= x <= N) & (0 <= y <= N)):
            print(int(x), int(y), z)
            break
else:
    print("-1 -1 -1")
n,y=map(int,input().split())
y=y//1000
if y<n or 10*n<y:
    print(-1,-1,-1)
else:
    for i in range((y-n)//9+1):
        if (y-n-9*i)%4==0:
            a=i
            b=(y-n-9*i)//4
            if n-a-b>=0:
                print(a,b,n-a-b)
                break
    else:
        print(-1,-1,-1)
N, Y = map(int, input().split())
x, y, z = 0, 0, 0
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:
            break
    if 10000*x + 5000*y + 1000*z == Y:
        break
    x, y, z = -1, -1, -1
print(x, y, z)
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')
# -*- coding: utf-8 -*-
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, y = map(int,input().split())
for i in range(n + 1): #10000
    for j in range(n + 1): #5000
        k = n - i - j #1000
        if k >= 0 and i * 10000 + j * 5000 + k * 1000 == y:
            print(i, j, k)
            exit()
print(-1, -1, -1)
n,y = map(int, input().strip().split())
a_x, a_y, a_z = -1, -1, -1
for xi in range(n + 1):
  for yi in range(n - xi + 1):
    zi = n - xi - yi
    if 10000*xi + 5000*yi + 1000*zi == y:
      a_x = xi
      a_y = yi
      a_z = zi
      break
 
print(a_x, a_y, a_z)
#input
N,Y = map(int,input().split())
#A = list(map(int, input().split()))
#print(N,Y)

ans = [-1,-1,-1]
#flag = True
# N = x + y + zを満たす組
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if z >= 0:
            list = [x,y,z]
            if Y == 10000*list[0]+5000*list[1]+1000*list[2]:
                ans = list
                break
print(ans[0],ans[1],ans[2])
N, Y = map(int, input().split())

Y //= 1000
a = b = c = -1

for i in range(N+1):
    for j in range(N+1):
        if (N-i-j) >= 0 and 9*i+4*j+N == Y:
            a = i
            b = j
            c = N-i-j
            break
    else:
        continue
    break

print(a, b, c)
n,y = (int(x) for x in input().split())
sol = False
for i in range(n+1):
    bb = (y - 10000*i) - 1000*(n-i)
    a = i
    if bb % 4000 == 0 and bb >= 0:
        b = bb // 4000
        c = n - i - b
        if c >= 0:
            sol = True
            break
if not sol:
    print('-1 -1 -1')
else:
    print(a,b,c)
n,y=map(int,input().split())
b=0
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)
            b=1
            break
    if b==1:
        break    
if b==0:
    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')
import sys
n,y = map(int, sys.stdin.readline().split())
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
    else:
        continue
    break
if 10000*a + 5000*b + 1000*c != y:
    print(-1,-1,-1)
N,Y=map(int,input().split())
a=0
b=0
c=0

for i in range(2001):
    for j in range(2001):
        k=N-i-j
        if 10000*i+5000*j+1000*k==Y and k>=0:
            
            a=i
            b=j
            c=N-i-j
        else:
            pass

if a==0 and b==0 and c==0:
    print(-1,-1,-1)
else:
    print(a,b,c)
N,Y = map(int,input().split())
x = 0
y = 0
z = 0
flag = False
for i in range(N+1):
  for j in range(N+1-i):
    if 0 <= (Y-10000*i-5000*j)/1000 and (Y-10000*i-5000*j)/1000 == N-i-j:
      x = i
      y = j
      z = N-i-j
      flag = True
      break
if flag == False:
  print(-1,-1,-1)
else:
  print(x,y,z)
N,Y = list(map(int, input().split()))
for i in reversed(range(min(N+1, Y//10000+1))):
    for j in reversed(range(min(N-i+1, (Y-10000*i)//5000+1))):
        k = N-i-j
        if i*10000 + j*5000 + k*1000 == Y:
            print(i, j, k)
            exit()

print(-1, -1, -1)
N, Y = map(int, input().split())
for n in range(N+1):
    for m in range(N+1-n):
        if 1000*n + 5000*m + 10000*(N-n-m) == Y:
            print(N-n-m, m, n)
            exit()
print(-1, -1, -1)
n, money = (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) == money:
            print(i, j, n-i-j)
            break
    else:
        if i == n:
            print(-1, -1, -1)
            break
        continue
    break
N,Y = map(int,input().split())
X = Y // 1000
check = 0
for a in range(X // 10 + 1):
    for b in range(X // 5 + 1):
        c = N - a - b
        Z = 10 * a + 5 * b + c
        if c >= 0 and X == Z:
            check = 1
            break
    if check == 1:
        break
if check == 0:
    print(-1,-1,-1)
else:
    print(a,b,c)
n,y = map(int,input().split())

ans = []

for i in range(n+1):#1000円
    for j in range(n+1-i):#5000円
        val = 1000 * i + 5000 * j + 10000 * (n-i-j)
        if val == y:
            ans.append(n-i-j)
            ans.append(j)
            ans.append(i)
            break

if ans:
    print(*ans[0:3])
else:
    print(-1,-1,-1)
n, y=map(int, input().split())
a=y//10000
b=y//5000
c=y//1000
y/=1000
for i in range(c+1):
    for j in range(n+1-i):
        k=n-i-j
        if i + 5*j + 10*k == y:
            print(k, j, i)
            exit()

print(-1, -1, -1)
n, y = map(int, input().split())

ans = [-1, -1, -1]
find = False
for i in range(n + 1):
  if find:
    break
  for j in range(n + 1):
    if i + j > n:
      break
    k = n - (i + j)
    total = 10000 * i + 5000 * j + 1000 * k
    if total == y:
      ans[0] = i
      ans[1] = j
      ans[2] = k
      find = True
      break

print('{0} {1} {2}'.format(ans[0], ans[1], ans[2]))
n,y=map(int,input().split())
y //= 1000
for i in range(n+1):
    for j in range(n-i+1):
        if 9*i + 4*j + n == y:
            print(i,j,n-i-j)
            exit()
print("-1 "*3)
n, y = map(int, input().split(' '))

flag=0
for i in range(n+1):
  for j in range(n+1-i):
    if i*10000 + j*5000 + (n-i-j)*1000 == y:
      print(str(i)+' '+str(j)+' '+str(n-i-j))
      flag=1
      break
  if flag==1:
    break
       
if flag==0:
  print('-1 -1 -1')
li = input().split()
count = int(li[0])
price = int(li[1]) / 1000
errorText = '-1 -1 -1'
ans = True
flag = False
for a in range(count+1):
    for b in range(count+1 - a):
        c = count - a-b
        fee = a*10 + b*5 + c*1
        if fee == price and a+b+c == count:
            print(str(a) + " " + str(b) + " " + str(c))
            ans = False
            flag = True
            break
    if flag:
        break

if ans is not False:
    print(errorText)
N, Y = [int(x) for x in input().split(" ")]

num = [-1,-1,-1]

for i in range(0,N+1):
  for j in range(0,N+1-i):
    if i*10000+j*5000+(N-i-j)*1000 == Y:
      num = [i,j,N-i-j]
      break

print(num[0],num[1],num[2])
import sys
N,Y=map(int,input().split())
count=0
n=N+1
for x in range(n):
  i=10000*x
  if i>Y:
    break
  for y in range(n):
    j=5000*y
    if j>Y:
      break
    z=N-x-y
    if z<0:
      continue
    if i+j+1000*z==Y:
      print(x,y,z)
      sys.exit()
print(-1,-1,-1)
n,y = map(int,input().split())
y = y//1000
flag = 0
for i in range(n+1):
    for j in range(n+1-i):
        if i*10 + j*5 + (n-i-j) == y:
            print(i, j, n-i-j)
            flag = 1
            break
    if flag == 1:
        break
if flag == 0:
    print('-1 -1 -1')
N, Y = map(int, input().split())

f = False
for i in range(N+1):
    if f:
        break
    for j in range(N+1-i):
        k = N-i-j
        if 10000*i+5000*j+1000*k == Y:
            print('{} {} {}'.format(i, j, k))
            f = True
            break
if not f:
    print('-1 -1 -1')
n, y = list(map(int, input().strip().split()))
f=0
a=-1
b=-1
c=-1
for i  in range(0,n+1):
    for j in range(0,n-i+1):
        x=i*10000+j*5000+(n-i-j)*1000
        if y==x:
           a=i
           b=j
           c=n-i-j
print(a,b,c)
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:
            ans = "{} {} {}".format(i, j, n - i - j)
            print(ans)
            j += 1
            exit()

else:
    print("-1 -1 -1")
N, Y = [int(_) for _ in input().split()]

for x in range(0, Y//10000 + 1, 1):
    for y in range(0, Y//5000 + 1, 1):
        
        z = N - x - y
        
        if z < 0:
            continue
        
        if 10000 * x + 5000 * y + 1000 * z == Y:
            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):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y:
            print("{} {} {}".format(i,j,k))
            exit(0)
print("-1 -1 -1")
N,Y = map(int,input().split())
for a in range(N+1):
    for b in range (N+1-a):
        if a*10000+b*5000+1000*(N-a-b) == Y:
            print(a,b,N-a-b)
            exit()
print(-1,-1,-1)
N,Y = map(int,input().split())
A,B,C = 0,0,0
flag = False
for i in range(N):
    if flag:
        break
    for j in range(N):
        if i*10000 + j*5000 + (N-i-j)*1000 == Y and (N-i-j) >= 0:
            A,B,C = i,j,(N-i-j)
            flag = True
            break
if A == B == C == 0:
    A,B,C = -1,-1,-1
print(A,B,C)
N, Y = map(int, input().split())
ans = False
for i in range(N+1):
  for j in range(N+1-i):
    k = N-i-j
    if 10000*i + 5000*j + 1000*k == Y:
      ans = True
      print(i, j, k)
    break
      
if ans == False:
  print(-1, -1, -1)
n, y = map(int, input().split())
count = 0
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)
            count += 1
        break
if count == 0:
    print(-1,-1,-1)
import sys
n,y=map(int,input().split())
if n*10000<y:
    print("-1 -1 -1")
    sys.exit()
if y//1000<n:
    print("-1 -1 -1")
    sys.exit()
m=y//10000
for i in range(m+1):
    g=(y-m*10000)//5000
    for j in range(g+1):
        s=(y-10000*i-5000*j)//1000
        if i+j+s==n and s>=0:
            print(i,j,s)
            sys.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*1000+j*5000+10000*(N-i-j) == Y:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1)
def resolve():

    N,Y=map(int,input().split())
    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,end=' ')
                print(j,end=' ')
                print(N-i-j)

resolve()
N,Y = map(int,input().split())
for x in range(N):
    for y in range(N):
        if Y == 10000*x+5000*y+1000*(N-x-y):
            print(x,y,N-x-y)
            exit()
print('-1','-1','-1')
# https://atcoder.jp/contests/abc085/tasks/abc085_c

# N枚、Y円
N, Y = map(int, input().split())

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

        if z < 0:
            continue

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

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

for i in range(9):
    a = Y - i*5000
    b = N-i
    if (b*10000 - a) % 9000 != 0:
        continue
    c = (b*10000 - a) // 9000
    d = b-c

    if c < 0 or d < 0:
        continue

    if N == c+d and Y == d*10000+i*5000+c*1000:
        print(d, i, c)
        break

else:
    print(-1,-1,-1)
otoshidama = list(map(int,input().split()))
flg = True
for i in range(otoshidama[0]):
    yukichi =i
    for n in range(otoshidama[0]-yukichi):
        higuchi = n
        noguchi = otoshidama[0] - yukichi - higuchi

        if 10000*yukichi+5000*higuchi+1000*noguchi==otoshidama[1]:
            print("{} {} {}".format(yukichi,higuchi,noguchi))
            flg = False

if flg:
    print("-1 -1 -1")
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))
 
inp = LI()
n,Y = [inp.pop(0) for _ in range(2)]
 
x = int(Y/10000)
y = int((Y-x*10000)/5000)
z = int((Y-x*10000-y*5000)/1000)
 
if x+y+z<=n:
    print(str(x)+' '+str(y)+' '+str(z))
else:
    print('-1 -1 -1')
n,y=map(int,input().split())
a=int(y/10000)
b=int((y-a*10000)/5000)
print(a,b)
if (y-a*10000-b*5000)%1000 == 0:
	print(a,b,int((y-a*10000-b*5000)/1000))
else:
	print(-1,-1,-1)
nums = []
nums = input().split()
N = int(nums[0])
Y = int(nums[1])
for c in range(N+1) :
    for b in range(N + 1):
        for a in range(N + 1):
            if( Y == 10000 * a + 5000 * b + 1000 *c ):
                break
        else:
            continue
        break
    else:
        continue
    break
if( N < (a + b + c)):
    print("-1 -1 -1")
else :
    print(a,b,c)
l = list(map(int,input().split()))
N = l[0]
Y = l[1]

S = 0
man = 0
gosen = 0
sen = 0

for i in range(1):
    while S <= Y-10000:
        S = S + 10000
        man += 1
    
    while S <= Y-5000:
        S = S + 5000
        gosen += 1
    
    while S <= Y-1000:
        S = S + 1000
        sen += 1       

    if man + gosen +sen > N:
        print("-1,-1,-1")
        break
    
    else:
        print(man,gosen,sen)
N, Y = map(int, input().split())
total = 0
for x in range(N + 1):
    for y in range(N + 1 - x):
        for z in range(N + 1 - x - y):
            if Y == 10000 * x + 5000 * y + 1000 * z:
                total = total + 1
                ans = str(x) + " " + str(y) + " " + str(z)
                print(ans)
                break
            else:
                continue
if total ==0:
    print("-1 -1 -1")
#N枚のお金N，合計金額Y
N, Y = map(int, input().split())
 
"""
a = 0 #1000円札の枚数
b = 0 #5000円札の枚数
c = 0 #10000円札の枚数
 
X = 0 #合計金額
"""
 
for a in range(N+1):
    for b in range(N-a+1):
        X = 1000*a + 5000*b + 10000*(N-a-b)
        if X == Y:
            print(a, b, N-a-b)
            exit()
 
 
print("-1 -1 -1")