peterverebics/CodeNet_Python_118 huggingface dataset:
n, y = map(int, input().split())

ans = [-1] * 3
i = 0

while i <= n:
    j = 0
    while j <= n-i:
        if i*10000 + j*5000 + (n-i-j)*1000 == y:
            ans[0] = i
            ans[1] = j
            ans[2] = n-i-j
        j += 1
    i += 1

print(ans[0], ans[1], ans[2])
def main():
    N, Y = map(int, input().split())
    m = 10000
    ft = 5000
    t = 1000
    for i in range(N+1):
        for j in range(N-i+1):
            k = N - i - j
            if m*i + ft*j + t*k == Y and i + j + k == N:
                print(str(i) + ' ' + str(j) + ' ' + str(k))
                return
    print('-1 -1 -1')

main()
N,Y = map(int,(input().split()))
r = Y - N*1000
if r < 0:
    print(-1,-1,-1)
else:
    for i in range(N+1): #5000
        for j in range(N+1-i): #10000
            if i*4000 + j*9000 == r:
                print(j,i,N-i-j)
                break
        else:
            continue
        break
    else:
        print(-1,-1,-1)
N, Y = map(int, input().split())

# 10000x + 5000y + 1000z = Y
# x + y + z = N
flg = False
loopCnt = 0
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        total = 10000*x + 5000*y + 1000*z
        if total == Y and z >= 0:
            print(x, y ,z)
            loopCnt += 1
            flg = True
            break
    if flg:
        break    

if loopCnt == 0:
    print(-1, -1, -1)
import sys
N, Y = map(int, input().split())

num = min(N, Y//10000)
if 10000*N < Y:
    print('-1 -1 -1')
    sys.exit()

for i in reversed(range(0, num+1)):
    for j in reversed(range(0, N-i+1)):
        if 10000*i + 5000*j > Y:
            continue
        if 10000*i + 5000*j + 1000*(N-i-j) == Y:
            print('%d %d %d' % (i, j, N-i-j))
            sys.exit()
print('-1 -1 -1')
n,y=map(int,input().split());print(*([(i,j,n-i-j)for i in range(n+1)for j in range(n-i+1)if 9*i+4*j+n==y/1e3]+[(-1,-1,-1)])[0])
import sys

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

for x in range(n + 1):
    for y in range(n + 1):
        z = (Y - 10000 * x - 5000 * y) / 1000
        if x + y + z == n and z >= 0 and z.is_integer():
            print(x, y, int(z))
            sys.exit()
print("-1 -1 -1")
import sys
n,y = map(int, input().split())
count = 0
for i in range(0,n+1):
    for j in range(0,n-i+1):
        a = 10000*i + 5000*j + 1000*(n-i-j)
        if (a == y):
            ans = [i,j,n-i-j]
            print(*ans)
            sys.exit()
ans = [-1,-1,-1]
print(*ans)
N,Y=map(int,input().split())
# N=9
# Y=45000
l=0
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:
            l=[i,j,k]
            pass
if l==0:
    l=[-1,-1,-1]
print(*l,sep=' ')
n,y = map(int,input().split())
ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n+1-i):
        k = n - i - j
        if (i*1000 + j*5000 + k*10000) == y:
            ans = str(k) + ' ' + str(j) + ' ' + str(i)
            break
print(ans)
n, y = map(int, input().split())
flag = False
for i in range(n+1):
    for j in range(n-i+1):
        k = n-i-j
        sum = i*10000 + j*5000 + k*1000
        if sum == y and flag == False:
            print(i, j, k)
            flag = True
if flag == False:
    print(-1, -1, -1)
n,X =map(int,input().split())
count=0
for a in range(n+1):
    for b in range(n+1):
            if 10000*a + 5000*b + 1000*(n-a-b) == X and n-a-b >=0 and count == 0:
                print(a,b,n-a-b)
                count+=1
if count==0:
    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())
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(i,j,k)
            exit()
else:
    print(-1,-1,-1)
n, Y = map(int, input().split())
a = 10000
b = 5000
c = 1000

for x in range(n+1):
    for y in range(n+1):
        z = n-x-y
        if z < 0:
            continue
        if a*x+b*y+c*z == Y:
            print(x, y, z)
            exit()
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())

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())
exists = False
for x in range(N+1):
  for y in range(N+1):
    z = (Y-10000*x-5000*y)//1000
    if 0<=z<=N and x+y+z==N:
      exists = True
      break
  else:
    continue
  break
if exists:
  print(x, y, z)
else:
  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):
            tmp = 10000 * i + 5000 * j + 1000 * (N - i - j)
            if tmp == Y:
                print(i, j, N - i - j)
                exit()

    print(-1,-1,-1)



if __name__ == "__main__":
    main()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
  N, Y = map(int, input().split())
  for i in range(0, N+1):
    for j in range(0, N+1):
      k = N - i - j
      if k < 0:
        continue
      if Y == 10000 * i + 5000 * j + 1000 * k:
        print(i, j, k)
        return
  print("-1 -1 -1")


if __name__ == "__main__":
    main()
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, m =map(int,input().split())
flg=0
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i+5000*j+1000*(n-i-j)==m:
            flg = 1
            print(i,j,n-i-j)
            break
    else:
        continue
    break
            
if flg==0:
    print(-1,-1,-1)
# -*- coding: utf-8 -*-
"""
Created on Tue Feb  4 00:34:00 2020

@author: yama
"""

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

f = False
for i in range(n+1):
    for j in range(n-i+1):
        k = (y - (i*10000 + j*5000))//1000
        if i + j + k == n and i*10000 + j*5000 + k*1000 == y:
            f = True
            break
    if f == True:
        break
    
if f == True:
    print(i, j, k)
else:
    print("-1 -1 -1")
n ,y = map(int, input().split())

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

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

def f():
  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:
        return i,j,k
  return -1,-1,-1

a,b,c = f()
print(a,b,c)
N, Y = map(int, input().split())

match = False
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        y = 10000*i + 5000*j + 1000*k
        if y == Y:
            match = True
            print(i, j, k)
            break
    if match:
        break

if not match:
    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 k >= 0:
            if 10000*i+5000*j+1000*k == y:
                print(i,j,k)
                exit()

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

def otoshidama():
    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)
                return
    print(-1, -1, -1)

otoshidama()
def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")

n,y = map(int, input().split())
print(calcPattern(n,y))
N, Y = map(int, input().split())
#print(N)
for x in range(N+1)[::-1]:
  for y in range(N+1-x)[::-1]:
    #print(x,y,N-x-y)
    if x*10000+y*5000+(N-x-y)*1000 == Y:
      print(x,y,N-x-y)
      exit(0)
print(-1,-1,-1)
N, Y = map(int, input().split())
# N = 9
# Y = 45000


def judge(n, target):
    for x in range(n+1):
        for y in range(n+1-x):
            z = n - x - y
            total = 10000 * x + 5000 * y + 1000 * z
            if total == target:
                return '{} {} {}'.format(x, y, z)
    return '-1 -1 -1'


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

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


if __name__ == '__main__':
    solve()
def main():
    N,Y = map(int, input().split())
    # N枚でY円はありえるかどうか
    for x in range(min(Y//10000+1, N+1)):
        for y in range(min((Y-x)//5000+1, N+1)):
            z = (Y-10000*x-5000*y)//1000
            if (Y-10000*x-5000*y)%1000==0 and z>=0 and (x+y+z)==N:
                ans = [x,y,z]
                print(*ans)
                return
    ans = [-1,-1,-1]
    print(*ans)
main()
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")
n, y = map(int, input().split())
y //= 1000
ans = [-1, -1, -1]
for i in range(y // 10 + 1):
    for j in range((y - i * 10) // 5 + 1):
        k = y - i * 10 - j * 5
        if i + j + k == n:
            ans = [i, j, k]
print(*ans)
n, Y = map(int, input().split())
Y //= 1000

for x in range(n+1):
    y = (Y-n-9*x)//4
    z = n-x-y
    if z < 0 or y < 0 or x+y+z != n:
        continue
    if 10*x+5*y+z == Y:
        print(x, y, z)
        exit()
else:
    print(-1, -1, -1)
n, total = map(int, input().split(" "))

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

for x_tmp in range(0, n + 1):
    for y_tmp in range(0, (n - x_tmp) + 1):
        z_tmp = n - (x_tmp + y_tmp) if n >= (x_tmp + y_tmp) else 0
        if total == (x_tmp * 10000 + y_tmp * 5000 + z_tmp * 1000):
            x, y, z = x_tmp, y_tmp, z_tmp

print(x, y, z, sep = " ")
N,Y = map(int,input().split())
result = [-1]*3
for i in range(N+1):
    for j in range(N-i+1):
        money = i * 10000 + j * 5000 + (N-i-j)*1000
        if money == Y :
            result = [i,j,(N-i-j)]
            break

print(*result)
import sys
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)
      sys.exit()
print("-1 -1 -1")
N, Y = map(int, input().split())
x, y, z = [-1]*3
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:
      x, y, z = i, j, k
      break
  else :
    continue
  break
print("{0} {1} {2}".format(x, y, z))
N,Y = map(int,input().split())

ten=-1
five=-1
one=-1

for i in range(N+1):
    for j in range(0, N-i+1):
        k = N-i-j
        if(10000*i + 5000*j + 1000*k == Y):
            ten = i
            five = j
            one = k

out = str(ten) + ' ' + str(five) + ' ' + str(one)
print(out)
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 and n - i - j >= 0:
             flag = 1
             print(i,j,n - i - j)
 if flag == 0:
     print('-1 -1 -1')
main()
x, y = map(int,input().split())

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

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

for i in range(n + 1):
  for j in range(n + 1):
    if (n - (i + j) >= 0) and (i * 10000 + j * 5000 + (n - (i + j)) * 1000 == y):
      print(str(i) + " " + str(j) + " " + str(n - (i + j)))
      exit()
else:
  print("-1 -1 -1")
import sys
n, y = map(int, input().split())

for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - i - j
        price = (i * 10**4) + (j * 5 * 10**3) + (k * 10**3)
        if price == y:
            print(i, j, k)
            sys.exit()
        elif y < price:
            break

print(-1, -1, -1)
N, Y = map(int, input().split())
Y //= 1000
tmp_a = Y//10 + 1
tmp_b = Y//5 + 1

for i in range(tmp_a):
    for j in range(tmp_b):
        k = N-(i+j)
        if k>=0 and 10*i+5*j+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+1-i):
        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())

tf = False

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:
            print(i, j, k)
            tf = True
            break
    else:
        continue
    break

if tf is False:
    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(i,j,k)
            exit()
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()
print("-1 -1 -1")
n,m = map(int, input().split())

for x in range(n, -1, -1):
  if m - 10000*x < 0: continue
  for y in range(n-x, -1, -1):
    z = n-x-y
    if 10000*x + 5000*y + 1000*z == m:
      print(x,y,z)
      exit()
print(-1,-1,-1)
import sys
list = input().split(" ")
N = int(list[0])
Y = int(list[1])

for yukichi in range(0,N+1):
    for ichiyo in range(0,N - yukichi + 1):
        hideyo = N - yukichi - ichiyo
        if 10000*yukichi + 5000*ichiyo + 1000*hideyo == Y:
            print(yukichi,ichiyo,hideyo)
            sys.exit()
 
print(-1,-1,-1)
n, y = map(int, input().split())
ans = [-1, -1, -1]
c = 0
for i in range(n + 1):
    if c == 1:
        break
    for j in range(n + 1 - i):
        yu = i
        hi = j
        no = n - i - j
        if no * 1000 + hi * 5000 + yu * 10000 == y:
            ans = [yu, hi, no]
            c = 1
print(" ".join(map(str, ans)))
N, Y = map(int, input().split())
ans = 0
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:
            print(i, j, N - i - j)
            exit()
print(-1, -1, -1)
n, y = map(int, input().split())
ans = [-1]*3
for i in range(0, int(y/10000)+1):
    ty = y-10000*i
    tn = n-i
    for j in range(0, min(int(ty/5000)+1,tn+1)):
        tty = ty-5000*j
        ttn = tn-j
        if tty%1000 == 0 and ttn==tty//1000:
            print(i, j, tty//1000)
            exit()
print(-1, -1, -1)
import sys
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)
            sys.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)
n,y = map(int, input().split())
n10, n5, n1 = -1, -1, -1
for i in range(n+1):
    for j in range(i, n+1):
        if i*10000 + (j-i)*5000 + (n - j)*1000 == y:
            n10 = i
            n5 = j-i
            n1 = n-j
            break
print(n10, n5, n1)
a,b = map(int,input().split())
for i in range(a+1):
    for j in range(a-i+1):
        z = a-i-j
        if 10000*i+5000*j+1000*z==b :
            print(i,j,z)
            exit()
print(-1,-1,-1)
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, Y = map(int, input().split())
    ret = [-1] * 3
    for x in range(N+1):
        tY = Y - 10000 * x
        tN = N - x
        for y in range(tN+1):
            z = tN - y
            if tY == y * 5000 + z * 1000:
                ret = [x, y, z]
                break
    print(*ret)

if __name__ == '__main__':
    main()
n, y = list(map(int, input().split()))

for i in range(2000+1):
    for j in range(2000+1):
        if i*10000 + j*5000 + (n-i-j)*1000 == y and (n-i-j)>=0:
            print(str(i) + ' ' + str(j) + ' ' + str(n-i-j) + ' ')
            exit()
print('-1 -1 -1')
n,Y=map(int,input().split())
x,y,z=-1,-1,-1
for i in range(n+1):
    total=10000*i
    for j in range(n-i+1):
        total2=total+5000*j
        if n-(i+j)==(Y-total2)//1000:
            x,y,z=i,j,n-(i+j)
            break
        #print(total2)
print(str(x)+" "+str(y)+" "+str(z))
import sys
n, y = map(int, input().split())

max10k = y // 10000

for i in range(max10k+1):
    max5k = (y - 10000 * i)//5000
    for j in range(max5k+1):
        if (y - 10000 * i - 5000 * j) // 1000 == n - i - j:
          print(i, j, (n - i - j))
          sys.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 z < 0:
            continue
        sm = 10000 * x + 5000 * y + 1000 * z
        if sm == Y:
            print(x, y, z)
            exit(0)
print(-1, -1, -1)
N,Y = map(int,input().split())
s=0
for x in range(2001):
  for y in range(2001):
    z = N - (x+y)
    if 1000*x + 5000*y + 10000*z == Y and z >=0:
      print(z,' ',y,' ',x)
      s = s+1
      break
  else:
    continue
  break
if s == 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("%d %d %d"%(i,j,n-i-j))
            exit()
print(-1,-1,-1)
N,Y = map(int, input().split())
"""
・10000x+5000y+1000z=Y
・x+y+z=N
・z=N-(x+y)>=0 x+y<=N
"""

for x in range(N + 1):
    for y in range(N + 1 - x):
        R = Y - 10000 * x - 5000 * y
        z = N - (x + y)
        if 1000 * z == R:
            print(x, y, z)
            exit()
print(-1, -1, -1)
n, y = list(map(int,input().split()))
flag = 0
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)
            flag = 1
            break
    if flag == 1:
        break
        
if flag == 0:
    print(-1,-1,-1)
N,Y = list(map(int, input().split()))
for i in reversed(range(N+1)):
    for j in reversed(range(N-i+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 i in range(n+1):
    for j in range(n-i+1):
        if y-10000*i-5000*j-1000*(n-i-j) == 0:
            print(i,j,n-i-j)
            exit()
print(-1,-1,-1)
n,y = map(int, input().split())

exist = False

for i in reversed(range(y//10000+1)):
    for j in reversed(range(n-i+1)):
        k = n - i - j
        res = y - 10000*i - 5000*j
        if res == 1000*k:
            print("{} {} {}".format(i,j,n-i-j))
            print("\n")
            exist = True
        if exist:
            break
    if exist:
        break

if not exist:
    print("-1 -1 -1")
    print("\n")
N, Y = map(int, input().split())

ans = [-1, -1, -1]
findit = False
sen = 0
for man in range(N + 1):
    for gosen in range(N + 1):
        sen = N - man - gosen
        if (man * 10000) + (gosen * 5000) + (sen * 1000) == Y and 0 <= sen:
            ans = [man, gosen, sen]

str_ans = map(str, ans)
print(" ".join(str_ans))
N, Y = map(int, input().split())
x = -1
y = -1
z = -1
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:
            x = i
            y = j
            z = k
print(x, y, z)
n, y = map(int, input().split())
ans = [-1, -1, -1]
for senen in range(n+1):
    for gosenen in range(n-senen+1):
        itimanen = n-senen-gosenen
        if senen*1000 + gosenen*5000 + 10000*itimanen == y:
            ans = [itimanen, gosenen, senen]
            break
    else:
        continue
    break


print(*ans)
l = list(map(int,input().split()))
N = l[0]
Y = l[1]

l = list()

for i in range(N+1):
    a = i
    if (Y - 1000*N -9000*a) % 4000 == 0:
        b = (Y - 1000*N -9000*a) // 4000 
        c = N - a - b
        if a >= 0 and b >= 0 and c >= 0:
            l.append([a,b,c])
            break

if len(l) ==0:
    print("-1 -1 -1")
else:
    ans = l[0]
    print(ans[0],ans[1],ans[2])
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline()).split())

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

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

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

Y //= 1000

for y in range(0, (10*N-Y)//5+1):
    for z in range(0, (10*N-Y-5*y)//9+1):
        if 10*N - Y == 5*y + 9*z:
            if N-y-z < 0:
                continue
            print(N-y-z, y, z)
            sys.exit()

print(-1, -1, -1)
N, Y = map(int,input().split())
c = Y//1000
for x in range(N+1):
    if (c-N-9*x) % 4 == 0:
        y = (c-N-9*x)//4
        if 0<=y<=N-x:
            print(x,y,N-x-y)
            exit(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-i*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")
from math import floor
N,Y = map(int,input().split(" "))
#x+y+z = N
#10000x+5000y+1000z = Y
#9000x+4000y=Y-1000N
ans = [-1,-1,-1]
for x in range(N+1):
  y = (Y-1000*N-9000*x)/4000
  if y >= 0 and y - floor(y) == 0:
    y = int(y)
    if N - (x + y) >= 0 and 10000*x + 5000*y + 1000*(N-x-y) == Y:
      ans = [int(x),y,int(N-(x+y))]
      break
print(*ans)
n, y = map(int, input().split())

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

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

for a in range(n+1):
  bc = n - a
  for b in range(bc+1):
    c = bc - b
    sum = 10000*a + 5000*b + 1000*c
    if sum == y:
      print(a, b, c)
      break
  else:
    continue
  break
else:
  print(-1, -1, -1)
import math
n,y = map(int,input().split())
y = y//1000
k = math.ceil(2*(y-n)/9)
if k*4 <= (y-n) and 5*k <= y:
  print(-4*k+y-n,9*k-2*(y-n),y-5*k)
else:
  print(-1,-1,-1)
din = list(map(int,input().split()))
NN = din[0]
YY = din[1]

found = 0
for n10000 in range(NN+1):
    if found == 1: break
    n_rem = NN - n10000
    n5000 = 0
    while ((n5000<=n_rem) and (found == 0)):
        n1000 = NN-n10000-n5000
        if YY - n10000*10000 - n5000*5000 - n1000*1000 == 0:
            line = "{} {} {}".format(n10000,n5000,n1000)
            print(line)
            found = 1;
        else:
            n5000 += 1
if found == 0:
    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(n-i-j,j,i)
        exit()
  print(-1,-1,-1)
  
if __name__=="__main__":
  main()
n,Y=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==Y and z>=0:
      print('{} {} {}'.format(x,y,z))
      
      exit()

print('{} {} {}'.format(-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())
res = -1, -1, -1

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

print(*res)
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('{} {} {}'.format(i,j,N-i-j))
      exit()
else:
  print('-1 -1 -1')