peterverebics/CodeNet_Python_118 huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math

N, Y = map(int, input().strip().split())
x = -1
y = -1
z = -1

for i in range(N+1):
    if i * 10000 > Y:
        break
    for j in range(N+1-i):
        z = int((Y - i * 10000 - j * 5000) / 1000)
        if i + j + z == N and z >= 0:
            x = i
            y = j
            break
    if not x == -1:
        break

print('{} {} {}'.format(x, y, z))
n,y = map(int, input().split())

for i in range(n):
    total = y - i * 10000
    for j in range(n):
        left = max((total - j * 5000) ,-1) 
        if (left // 1000) == (n - i - j) and left % 1000 == 0:
            print("{} {} {}".format(i,j,n-i-j))
            exit()

print("-1 -1 -1")
n, y = map(int, input().split())
ans=[]
for i in range(n):
    for j in range(n):
        if i+j<=n:
            k=n-i-j
        else:
            k=0
        if 10000*i+5000*j+1000*k==y and i+j+k==n:
            ans+=i,j,k
            break
    else :
        continue
    break

if len(ans)==0:
    ans+=-1,-1,-1

print(ans[0],ans[1],ans[2])
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:
            print(a, b, c)
            exit()
print('-1 -1 -1')
N, Y = list(map(int, input().split()))

flag = False
for x in range(N):
  for y in range(N-x):
    z = N - x - y
    if Y == 10000 * x + 5000 * y + 1000 * z:
      print(x, y, z)
      flag = True
      quit()
if flag:
  print("-1 -1 -1")
[N,Y] = list(map(int,input().split(' ')))

t = int(Y/1000 - N)
x = -1
y = -1
z = -1
for i in range(min(N, int(t/9))):
  if (int((t - 9*i)/4) == (t - 9*i)/4) and (N - i - int((t - 9*i)/4) >= 0):
    x = i
    y = int((t - 9*i)/4)
    z = N - x - y
    break
  elif ((t - 9*i)/4 < 0):
    break
  else:
    continue
    
print('{0} {1} {2}'.format(x,y,z))
n, y = map(int, input().split())

a = -1   # 10000
b = -1   # 5000
c = -1   # 1000

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

print("{} {} {}".format(a, b, c))
n, y = map(int, (input().split()))

for i in range(21):
    a = i
    b = (y-10000*a-1000*n+1000*a) / 4000
    c = n-a-b
    if b == int(b) and c == int(c) and b >= 0 and c >= 0:
        print(a, int(b), int(c))
        exit()
print(-1, -1, -1)
number,summ = list(map(int,input().split()))
for a in range(number+1):
  for b in range(number+1):
    c = number-a-b
    tmp = 1000*a + 5000*b + 10000*c
    if tmp == summ:
      print(a,b,c)
      exit()
N, Y = list(map(int, input().split()))

answer1 = -1
answer2 = -1
answer3 = -1
for i in range(N + 1):
    for j in range(N + 1):
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y:
            answer1 = i
            answer2 = j
            answer3 = k

print(str(answer1) + " " + str(answer2) + " " + str(answer3))
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-n+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")
a,b = map(int,input().split())
flag = 0

for i in range(a):
  for j in range(a):
    nokori = b - ((i * 1000) + (j * 5000))
    if nokori%10000 == 0 and nokori >= 0:
      k = int(nokori/10000)
      if (i+j+k)==a:
        flag = 1
        break
    elif nokori == 0 and (i+j) == a:
      k = 0
      flag = 1
      break
      
  if flag == 1:
    break
if flag == 1:
  print(i,j,k)
else:
  print("-1 -1 -1")
N, Y = list(map(int, input().split()))
result = '-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:
            result = '{} {} {}'.format(x, y, z)
            break

print(result)
N, Y = map(int, input().split())
Y /= 1000
flag = False
for i in range(N+1):
    if flag:
        break
    for j in range(N+1):
        if N - i - j < 0:
            break
        if Y - 10 * i - 5 * j == N - i - j:
            flag = True
            print(i, j, N-i-j)
        else:
            break
if flag == False:
    print(-1,-1,-1)
def main():
  n,y=map(int,input().split())
  for i in range(n+1):
    for j in range(n+1-i):
      if 10**3*(i+5*j+10*(n-i-j))==y:
        print(i,j,n-i-j)
        exit()
  print(-1,-1,-1)
  
if __name__=="__main__":
  main()
n, money = map(int, input().split())
ans = [0, 0, 0]
flag = False

for i_1000 in range(n+1):
  for j_5000 in range(n - i_1000 + 1):
    if (money - i_1000 * 1000 - j_5000 * 5000) == 10000 * (n - i_1000 - j_5000):
      flag = True
      ans = [i_1000, j_5000, n - i_1000 - j_5000]
      
  if flag:
    break

print(ans[0], ans[1], ans[2])
n, yen = map(int, input().split())

x = y = z = -1

for a in range(n):
    for b in range(n-a):
        num = n - a - b
        if (10000*a + 5000*b + 1000*num) == yen:
            x = a
            y = b
            z = num
            break

print(x, y, z)
n, y = map(int, input().split())
flg = 0
for i in range(n+1):
    for j in range(n+1):
        m = (y-1000*i-5000*j)/10000
        if m+i+j == n:
            flg = 1
            a=i
            b=j
            c=int(m)
if flg == 1:
    print(c,b,a)
else:
    print(-1,-1,-1)
all = list(map(int, input().split()))

N = all[0]
Y = all[1]

yu = -1
hi = -1
no = -1
for i in range(N):
    for j in range(N-i):
        c = (N-(i+j))
        total = 10000*i + 5000*j + 1000*c
        if Y!=total:
            continue
        else:
            yu = i
            hi = j
            no = c
            break
    else:
        continue 
    break

print(yu)
print(" ")
print(hi)
print(" ")
print(no)
print(" ")
N, Y = map(int, input().split())
x_out, y_out, z_out = -1, -1, -1
for x in range(N+1):
    for y in range(N-x):
        z = N - x - y
        xyz_sum = x*10000 + y*5000 + z*1000
        if xyz_sum == Y:
            x_out, y_out, z_out = x, y, z
            break
print(x_out, y_out, z_out)
N,Y=map(int, input().split())

ans=False

for man in range(N+1):
    for gosen in range(N-man+1):
        for sen in range(N-man-gosen):
            if man*10000+gosen*5000+sen*1000==Y:
                print(str(man)+" "+str(gosen)+" "+str(sen))
                ans=True
                exit()



if not ans:
    print("-1 -1 -1")
N,y = [int(x) for x in input().split()]
y = y // 1000
for i in range(y//5+1):
  nokori = i*5
  kosuu = y - i*5
  if kosuu > N:
    continue
  if kosuu == N and nokori == 0:
    print("0 0 " + str(y-i*5))
    exit()
  for j in range(nokori//10+1):
    kosuu = kosuu + j + (nokori-10*j)//5
    if kosuu == N:
      print(str(j)+" "+str((nokori-10*j)//5)+" "+str(y-i*5))
      exit()
print("-1 -1 -1")
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')
n, y = LI()

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

for x in range(N+1):
  if 10000*x > Y:
    break
  for y in range(N-x+1):
    if 10000*x + 5000*y > Y:
      break
    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 i in range(n+1):
  if (Y-1000*n-9000*i)%4000==0 and (Y-1000*n-9000*i)>=0 and (Y-1000*n-9000*i)//4000<=n and n-i-(Y-1000*n-9000*i)>=0 and n-i-(Y-1000*n-9000*i)//4000<=n:
    print("{} {} {}".format(i,(Y-1000*n-9000*i)//4000,n-i-(Y-1000*n-9000*i)//4000))
    exit()
print("{} {} {}".format(-1,-1,-1))
N,Y = map(int,input().split())

arr = []

for i in range(N+1):
    for j in range(N+1):
        k = N-i-j
        if i*10000+j*5000+k*1000 == Y and k>0:
            arr.append([i,j,k])

if len(arr) >0:
    print(arr[0][0],arr[0][1],arr[0][2])
else:
    print(-1,-1,-1)
import sys
input=sys.stdin.readline
n,y=map(int,input().split())
y10,y5,y1=0,0,0
for i in range(n+1):
    for j in range(n+1):
        for k in range(n+1):
            if 10000*i+5000*j+1000*k==y and i+j+k==n:
                print(i,j,k)
                exit(0)
n, y = map(int, input().split())

for a in range(n+1):
    for b in range(n+1):
        c = max(n - (a + b), 0)
        if 10000*a + 5000*b + 1000*c == y:
            print(a, b, c)
            exit()
print(-1, -1, -1)
n,y=map(int,input().split())
y //=1000
for i in range(n):
    for j in range(n):
        if n -(i+j) < 0:
            break
        if 9*i+4*j+n == y:
            print(i,j,n-(i+j))
            exit()
print('-1','-1','-1')
import sys
N,Y=map(int,input().split())
ans=0
for x in range (N):
    for y in range(N):
        if 10000*x+5000*y+1000*(N-x-y)==Y:
            print(str(x)+' '+str(y)+' '+str(N-x-y))
            sys.exit()
print(-1,-1,-1)
N,Y = map(int,input().split())
for x in range(1,N+1):
    for y in range(N-x+1):
        z_m = Y-(10000*x+5000*y)
        z_n = N-x-y
        if z_m >=0 and z_m//1000 == z_n:
            print(x,y,z_n)
            exit()
print(-1,-1,-1)
N,Y = map(int,input().split())
flag = False
for i in range(N+1):
    for j in range(N+1-i):
        x = N - i - j
    if x*1000 + j*5000 +i*10000 == Y:
        print('{0} {1} {2}'.format(i ,j,x ))
        flag = True
        break
    

if flag == False:
    print('-1 -1 -1')
N,Y=map(int,input().split())

xyz=[]
for x in range(N+1):   
    for y in range(N-x+1):
        z=N-(x+y)
        total=10000*x+5000*y+1000*z
        if total==Y:
            xyz.append([x,y,z])
if xyz:
    print(xyz[0])
else:
    print([-1,-1,-1])
N, Y = map(int, input().split())

Y //= 1000

for y in range(9):
  Y -= 5 * y
  N -= y
  if Y >= 0 and N >= 0:
    x, p = divmod(Y - N, 9)
    z, q = divmod(10*N - Y, 9)
    if p == 0 and q == 0 and x >= 0 and z >= 0:
      print(x, y, z)
      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 1000*xi + 5000*yi + 10000*zi == y:
      a_x = xi
      a_y = yi
      a_z = zi
      break

print(a_x, a_y, a_z)
[N,Y] = list(map(int,input().split(' ')))

t = int(Y/1000 - N)
x = -1
y = -1
z = -1
for i in range(min(N, int(t/9))):
  if ((t - 9*i)/4 < 0):
    break
  elif (int((t - 9*i)/4) == (t - 9*i)/4) and (N - i - int((t - 9*i)/4) >= 0):
    x = i
    y = int((t - 9*i)/4)
    z = int(N - x - y)
    break
  else:
    continue
    
print('{0} {1} {2}'.format(x,y,z))
N, Y = map(int, input().split())

Y = Y // 1000
k10, k5, k1 = -1, -1, -1
success = False
price = 0

for i in range(N+1):
  price = i * 10
  if price == Y:
    k10, k5, k1 = i, 0, 0
    success = True
    break

  for j in range(N-i+1):
    k = N - i - j
    price = i * 10 + j * 5 + k * 1
    if price == Y:
      k10, k5, k1 = i, j, k
      success = True
      break

  if success:
    break

print(k10, k5, k1)
n,y = map(int,input().split())
y = y // 1000
man,gosen,sen = 0,0,0
sen = y % 5
y -= sen
n -= sen

for i in range(y//10+1)[::-1]:
  amount = y - i*10
  for j in range(0,n-i+1,5):
    amount -= j + (n-i-j)*5
    if amount == 0:
      print(i,j,(n-i-j))
      exit(0)
    if amount < 0:
      print('-1 -1 -1')
      exit(0)
n,y = list(map(int, input().split()))
a = 0
b = 0
c = 0
if 10000*n < y:
  print("-1 -1 -1")
elif 10000*n == y:
  print("%d -1 -1" %n)
else:
  for i in range(n+1):
    for j in range(n+1):
      for k in range(n+1):
        if 10000*i+5000*j+1000*k == y:
          a = i
          b = j
          c = k
          break
  print("%d %d %d" %(a, b, c))
N, Y =map(int, input().split())
X = [-1,-1,-1]
for i in range(2000):
  y = (Y-1000*N-9000*i)/4000
  if not float.is_integer(y):
    continue
  if 0<= N-i-y <= 2000 and 0<= y <= 2000 and 0 <= i <= 2000:
    X=[i, y, N-i-y]
    X=list(map(int, X))
    break
print(*X)
N, Y = map(int, input().split())

x_max = Y // 10000
y_max = Y // 5000
z_max = Y // 1000
flag = False
for x in range(x_max +1):
    if flag == True:
        break
    if (N-x)*5000 > Y-10000*x:
        for y in range(N-x+1):
            for z in range(N-x-y+1):
                if 10000*x + 5000*y + 1000*z == Y and x+y+z == N:
                    print(x,y,z)
                    flag = True
if flag == False:
    print(-1, -1, -1)
# 085 C
N,Y = map(int, input().split())
x,y,z = -1,-1,-1
for i in range(N):
    for j in range(N):
        if ((10000*i + 5000*j + 1000*(N-i-j)) == Y)and(N-i-j>=0):
            x,y = i,j
            z = N - i - j
            break
    else:
        continue
    break
print(x,y,z)
N,Y=map(int,input().split( ))
x=N
y=0
z=0

def judg(x,y,z):
  if Y==x*10000+y*5000+z*1000:
    print(x,y,z)
    exit()

for i in range(N+1):
  x1=x-i
  y=i
  if Y==x1*10000+y*5000+z*1000:
    print(x1,y,z)
    exit()
  else :
    for j in range(i+1):
      y1=y-j
      z1=z+j
      judg(x1,y1,z1)
n, y = list(map(int, input().split()))

flag = True
for i in range(n):
    for j in range(n-i):
        if 10000*i+5000*j+1000*(n-i-j) == y:
            print(i, j, n-i-j)
            flag = False
            break
if flag:
    print(-1, -1, -1)
# coding: utf-8

# https://atcoder.jp/contests/abc085/tasks/abc085_c
# 19:24-19:34


def main():
    N, Y = map(int, input().split())
    y = Y // 1000

    for b in range(N+1):
        if (y-N-4*b) % 9 == 0:
            c = (y-N-4*b) // 9
            a = N - b - c
            if a >= 0:
                return "{} {} {}".format(c, b, a)

    return "-1 -1 -1"


print(main())
input_str = input().split()
N = int(input_str[0])
Y = int(input_str[1])

x_quo = Y//10000

for x in range(0,x_quo+1):
  Y_x = Y - 10000*x
  y_quo = Y_x // 5000
  for y in range(0,y_quo+1):
    Y_xy = Y_x - 5000*y
    z_quo = Y_xy // 1000
    for z in range(0,z_quo+1):
      if 10000*x + 5000*y + 1000*z == Y and x+y+z == N:
        break;
    else:
      continue
    break
  else:
    continue
  break

print(str(x) + " " + str(y) + " " + str(z))
N, Y = [int(n) for n in input().split(' ')]

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

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

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

    else:
        continue
    break

print(str(x)+' '+str(y)+' '+str(z))
import math
import sys
input = sys.stdin.readline


N,Y = map(int, input().split())
flag=0
for i in range(0,N+1):
    for j in range(0,N-i):
        if(Y-10000*i-5000*j)/1000 == N-i-j :
            a = i
            b = j
            c = N-i-j
            flag =1
            print(a,b,c)
            break
        if flag==1:
            break


if flag!=1:
    print("-1 -1 -1")
n,y=map(int,input().split())

for i in range(n+1):
    ai=10000*i
    if ai > y: continue
    else:
        for j in range(n+1-i):
            bj=5000*j
            if ai + bj > y :break
            else : 
                k=n-i-j
                if  ai + bj + 1000*k == y:
                    print(i,j,k)

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

itiman = y // 10000
gosen = (y - (itiman * 10000)) // 5000
sen = (y - (itiman * 10000 + gosen * 5000)) // 1000



while itiman + gosen + sen < n:
  if gosen == 0:
    gosen += 2
    itiman -= 1
  else:
    gosen -= 1
    sen += 5

if itiman + gosen + sen > n:
  print("-1 -1 -1")
else:
  print(str(itiman) + " " +  str(gosen) + " " + str(sen))
n ,y = map(int, input().split())
res = [-1,-1,-1]
for i in range(n):
  for j in range(n+1-i):
    ans = 10000*i + 5000*j +1000*(n-i-j)
    if ans == y :
      res =[i , j, n-i-j] 
      break
print(*res)
N,Y=map(int,input().split())

x=y=z=0
while N and 5000*N<Y:
    Y-=10000
    N-=1
    x+=1

while N and 1000*N<Y:
    Y-=5000
    N-=1
    y+=1

z=N

if z*1000==Y:
    print(x,y,z)
else:
    print(-1,-1,-1)
n,s = map(int, input().split())

for x in range(n):
    for y in range(n):
        tmp = n-x-y
        tmp2 = s-x*10000-y*5000
        if tmp*1000 == tmp2 and tmp >= 0:
            print('{} {} {}'.format(x,y,tmp))
            exit(0)

print('-1 -1 -1')
main_list = input().split()
n = int(main_list[0])
y = int(main_list[1][:-3])

for i in range(n+1):
    for j in range(n-i+1):
        if y == i*10 + j*5 + (n-i-j)*1:
            print(" ".join(list(map(str,[i,j,n-i-j]))))
        elif y > i*10 + j*5 + (n-i-j)*1 + 5:
            break

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

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

print('-1 -1 -1')
N,Y = map(int,input().split())
A,B,C = -1,-1,-1
flag = False
for i in range(N):
    if flag:
        break
    for j in range(N-i):
        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
print(A,B,C)
N, Y = map(int, input().split())

if Y // 1000 == N:
  print('0 0',N)

man_max = Y // 10000
gosen_max = Y // 5000

is_exist = False

for i_m in range(man_max+1):
  for i_g in range(gosen_max+1):
    if 99000*i_m + 4000*i_g == Y - 1000*N:
      print(i_m, i_g, int(Y / 1000 - 10*i_m - 5*i_g))
      is_exist = True
      break
  if is_exist:
    break
      
if not is_exist:
  print(-1, -1, -1)
n,y = map(int,input().split())
ans = [[-1, -1, -1]]
for i in range(n):
    for j in range(n):
        for k in range(n):
            if (10000 * i + 5000 * j + 1000 * k == y) & (i+j+k==9):
                ans.append([i,j,k])
                break
print(ans[-1])
N, Y = map(int,input().split())

def answer():
    for n_1000 in range(N+1):
        for n_5000 in range(N+1):
            n_10000 = N - n_1000 - n_5000
            if n_10000 < 0:
                continue
            if n_1000 * 1000 + n_5000 * 5000 + n_10000 * 10000 == Y:
                return (n_1000, n_5000, n_10000)
    return (-1, -1, -1)
                
print(" ".join(list(map(str,answer()))))
N,Y = [int(x) for x in input().split()]

def func(N,Y):
    a=Y//N
    if 10000*a==Y:
        return a,0,0
    for m in range(N-1,-1,-1):
        for i in range(0,m+1):
            if 10000*m+5000*i+1000*(N-m-i)==Y:
                return m,i,N-m-i
                
    return -1,-1,-1
    
a,b,c=func(N,Y)
print(a,b,c)
import sys

num = sys.stdin.readline().split(' ')
N = int(num[0])
Y = int(num[1])


for x in range(N+1):
    for y in range(N+1):
        if 1000 * x + 5000 * y + 1000*(N-x-y) == Y:
            print(str(x)+' '+str(y)+' '+str(N-x-y))
            sys.exit()
        else:
            continue

print('-1 -1 -1')
n,y = [int(i)  for i in input().split()]
c3 = int(y%5000/1000)
#print(c3)
y -= c3*1000
n -= c3
for i in range(2001):
  for j in range(2001):
    if 10000*(i)+5000*(j)+1000*(n-i-j) == y:
      print(i,j,n-i-j+c3)
      exit()
print(-1,-1,-1)
N, Y = list(map(int, input().split()))
final_ans = None
for i in range(N + 1):
    for j in range(N + 1):
        ans = i * 10000 + j * 5000 + (N - i - j) * 1000
        if ans == Y:
            final_ans = " ".join([str(i), str(j), str(N - i - j)])
            break

if final_ans is None:
    print('-1 -1 -1 ')
else:
    print(final_ans)
n,y = map(int, input().split())
a,b,c = -1,-1,-1
for i in range(n):
    for j in range(n):
        total = 10000*i + 5000*j + 1000*(n-i-j)
        if(total == y and (n-i-j)>0):
            a,b,c = i,j,(n-i-j)
print(a,b,c)
n,y = map(int,input().split())
u = [10000,5000,1000]
x = []
for i in range(0,n+1):
    for j in range(0,n-i+1):
        w = n-i-j
        if u[2]*i+u[1]*j+u[0]*w == y:
              x = [w,i,j]
              break

if len(x) == 0:
    print("-1 -1 -1")
else:
    print(" ".join(map(str,x)))
N, Y = map(int, input().split())
baloon = True
for x in range(N+1):
  for y in range(N+1):
    z = N-x-y
    if 10000*x + 5000*y + 1000*z == Y:
      print(str(x) + ' ' + str(y) + ' ' + str(z))
      baloon = False
      break
if baloon:
  print('-1 -1 -1')
n, y = map(int, input().split())
for i in range(n):
  for j in range(n):
    if 10000*n - 5000*i - 9000*j == y:
      print(n-i-j, i, j)
      quit()
print(-1,-1,-1)
N, Y = map(int, input().split())

flag = False
for x in range(N):
    for y in range(N):
        z = N - x - y
        if x + y + z == N and z >= 0:
            if Y == 10000 * x + 5000 * y + 1000 * z:
                print(x, y, z)
                flag = True
                break
    if flag:
        break
if not flag:
    print(-1, -1, -1)
n,y=map(int,input().split())
a=False
for i in range(n):
    for j in range(n-i):
        nogu=1000*i
        higu=5000*j
        huku=10000*(n-i-j)
        if nogu+higu+huku==y:
            print(n-i-j,j,i)
            a=True
            break
    if a==True:
        break
if a==False:
    print('-1 -1 -1')
n, y = map(int, input().split())

a = -1
b = -1
c = -1
k = 0

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

print(a, b, c)
n,y = map(int,input().split())
d = 0

for a in range(n):#10000
    for b in range(n):#5000
        c = n - a - b
        x = 10000*a + 5000*b + 1000*c
        if x == y and c >=0:
            print("{} {} {}".format(a,b,c))
            d =1
            break
    else:
        continue
    break



if d == 0:
    print("-1 -1 -1")
n,y=list(map(int, input().strip().split()))
a=-1
b=-1
c=-1
for i in range(n+1):
    for j in range(n-i+1):
        s=(y-10000*i-5000*j)
        if s%1000==0 and s>=0:
            a=i
            b=j
            c=s//1000
            break
print(a,b,c)
N,Y = map(int,input().split())

for i in range(N):
    for j in range(N):
        if N-i-j>=0:
            if 10000*i+5000*j+1000*(N-i-j)==Y:
                print(i,j,N-i-j)
                exit()
print('-1','-1','-1')
N, Y = map(int, input().split())

if Y // 1000 == N:
  print(0, 0, N)

man_max = Y // 10000
gosen_max = Y // 5000

is_exist = False

for i_m in range(man_max+1):
  for i_g in range(gosen_max+1):
    if 99000*i_m + 4000*i_g == Y - 1000*N:
      print(i_m, i_g, int(Y / 1000 - 10*i_m - 5*i_g))
      is_exist = True
      exit()
      
print(-1, -1, -1)
n, y = list(map(int, input().split()))
result = [-1, -1, -1]
for m_10000 in range(n + 1):
    for m_5000 in range(n + 1 - m_10000, n + 1):
        m_1000 = n - m_10000 - m_5000
        k = 10000 * m_10000 + 5000 * m_5000 + 1000 * m_1000
        if k == y:
            result = [m_10000, m_5000, m_1000]
            break

    else:
        continue
    break
print("{} {} {}".format(result[0], result[1], result[2]))
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 N == c+d and Y == d*10000+i*5000+c*1000:
        print(d, i, c)
        break

else:
    print(-1,-1,-1)
n, result = map(int, input().split())

for x in range(n + 1):
  for y in range(n + 1):
    for z in range(n + 1):
      if x + y + z == 9:
        if (10000 * x) + (5000 * y) + (1000 * z) == result:
          print(x, y, z)
          exit()

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

flg = True
for i in range(n+1):
    for j in range(n+1-i):
        for k in range(n+1-(j+i)):
            if (10000*k + 5000*j + 1000*i) == y:
                print('{} {} {}'.format(i, j, k))
                flg = False
                break
        if not flg:
            break
    if not flg:
        break
if flg:
    print('-1 -1 -1')
N,Y=map(int,input().split())

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