peterverebics/CodeNet_Python_118 huggingface dataset:
N, Y = map(int, input().split())

a = 10000
b = 5000
c = 1000

# p = 1 q = 1
# cの枚数 = 5


is_ok = False
for p in range(N+1):
    for q in range(N-p+1):
        tmp = Y - a * p - b * q
        if tmp == 0 or (tmp % c == 0 and tmp / c <= N-p-q):
            is_ok = True
            break
    if is_ok:
        break
if is_ok:
    print('{} {} {}'.format(p, q, N-p-q))
else:
    print('-1 -1 -1')
def main():
    N, Y = (int(i) for i in input().split())
    for i in range(N):
        for j in range(N):
            k = Y - 10000*i+5000*j
            if k % 1000 or k < 0:
                continue
            k //= 1000
            if i+j+k == N:
                return print(i, j, k)
    print(-1, -1, -1)


if __name__ == '__main__':
    main()
N,Y = input().split()
N,Y = map(int,(N,Y))
Z = Y
for i in range(2,N+1):
  Y = Y-10000*i
  for j in range(N+1-i):
    Y = Y-5000*j
    Y = Y-1000*(N-i-j)
    if Y == 0:
      print(i,end = " ")
      print(j,end = " ")
      print(N-i-j,end = " ")
      break
    else :
      Y=Z-i*10000
  else:
    Y = Z
    continue
  break
else :
  print(-1,end=" ")
  print(-1,end=" ")
  print(-1,end=" ")
N,Y=map(int,input().split())
l=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)
    break
            
else :
    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 (1000*x+5000*y + (N-x-y)* 10000 == Y) and ((N-x-y)>=0):
            print('%d %d %d' % (x,y,N-x-y))
            sys.exit(0)
N, Y = map(int, input().split())

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

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

f = False

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)
            f = True
        else:
            pass

if f:
    pass
else:
    print("-1 -1 -1")
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 == 0:
      flag = True
      ans = [i_1000, j_5000, n - i_1000 - j_5000]
      
  if flag:
    break

print(ans[0], ans[1], ans[2])
n, y = map(int, input().split())
ans1 = -1
ans2 = -1
ans3 = -1
for i in range(n):
    for j in range(n-(i+1)):
        if 10000*i + 5000*j + (n-(i+j))*1000 == y:
            ans1 = i
            ans2 = j
            ans3 = n-(i+j)
            break
print(ans1, ans2, ans3)
import math
n,y = map(int,input().split())
c = 0
for a in range(n):
	for b in range(n):
		if 9000*a + 4000*b == y - 1000*n and n - a - b >= 0:
			print(*[a,b,n-a-b])
			c += 1
			break
	if c == 1:
		break
if c == 0:
	print(*[-1,-1,-1])
N, Y = map(int, input().split())

for i in range(9):
    a = Y - i*5000
    b = N-i
    
    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)
n,y = map(int,input().split())
for a in range(n):
    for b in range(n):
        for c in range(n):
            if 10000*a + 5000*b + 1000*c == y and a + b + c == n:
                print(a,b,c)
                exit()
print(-1,-1,-1)
N,Y=map(int,input().split())
x = -1
y = -1
z = -1
for i in range(N+1):
    for j in range(N):
        k=N-j-i
        sum = i*10000 + j*5000 + k*1000
        if Y==sum:
            x=i
            y=j
            z=k
            break

    else:
        continue
    break

print(str(x)+' '+str(y)+' '+str(z))
import itertools
import sys

N, Y = map(int, input().strip().split(' '))
x = list(range(Y // 10000 + 1))
y = list(range(Y // 5000 + 1))
z = list(range(Y // 1000 + 1))

for i, j, k in itertools.product(x, y, z):
  if 10000 * i + 5000 * j + 1000 * k == Y:
    print(i, j, k)
else:
  print('-1 -1 -1')
import sys
import numpy as np

# N お札の枚数 Y お年玉の金額
n, y = map(int, input().split())

ok = False
for i in range(n):
    for j in range(n-i):
        for k in range(n-i-j):
            money = 10000 * i + 5000 * j + 1000 * k
            if (money == y):
                ok = True
                break
        if ok:
            break
    if  ok:
        break
if ok:
    print(i, j, k)
else:
    print("-1 -1 -1")
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

def solve():
    N, Y = mapint()
    for i in range(N+1):
        for j in range(N-i+1):
            now = i*10000 + j*5000
            if now>Y:
                continue
            if i+j+(Y-now)//1000==N:
                return (N-i-j, j, i)
    else:
        return (-1, -1, -1)

print(*solve())
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)
import sys
N,Y = map(int,input().split())
ans = '-1 -1 -1'

for i in range(2001):
    for j in range(2001):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y :
            print(str(i) + ' '+str(j) + ' '+ str(N-i-j))
            sys.exit()
print(ans)
N, Y = map(int, input().split())

for x in range(N):
    for y in range(N):
        z = N - x - y
        if 0 <= z <= N and 10000*x+5000*y+1000*z == Y :
            print("{} {} {}".format(x,y,z))
            exit()
print("-1 -1 -1")
N,Y = map(int,input().split())
x = 0
y = 0
z = 0
for i in range(N):
  for j in range(N):
    if int((Y-10000*i-5000*j)/1000) == N-i-j:
      x = i
      y = j
      z = N-i-j
      break
    break
if x == y == z == 0:
  print(-1,-1,-1)
else:
  print(x,y,z)
import sys
N, Y = map(int, input().split())

for m in range(N):
    for g in range(N-m):
        s = N - m - g
        if Y == 10000*m + 5000*g + 1000*s:
            print(m, g, s)
            sys.exit()

print(-1, -1, -1)
N, Y = list(map(int, input().split()))
results = [-1, -1, -1]
for x in range(N + 1):
    for y in range(N - x + 1):
        if Y == 10000 * x + 5000 * y + 1000 * (N - x - y):
            results = [x, y, (N - x - y)]
            print(results)
            exit()
N, Y = map(int, input().split())
res10000 = -1
res5000  = -1
res1000  = -1
for a in range(N + 1):
    for b in range(N + 1):
        c = N - a - b
        total = 10000*a + 5000*b + 1000*c
        if total == Y:
            res10000 = a
            res5000  = b
            res1000  = c
print('{} {} {}'.format(res10000, res5000, res1000))
n,y = [int(i)  for i in input().split()]
for i in range(2001):
  for j in range(0,n-i):
      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, -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 = [senen, gosenen, itimanen]
            break

print(*ans)
N,Y = map(int, input().split())

x = -1
y = -1
z = -1
sum = 0
for a in range(N):
    for b in range(N - a):
        c = N - a - b
        sum = 10000 * a + 5000 * b + 1000 * c
        if (sum == Y):
            x,y,z = a,b,c
print(x,y,z)
N, Y = map(int, input().split())
a = 0
b = 0
c = 0
for i in range(N):
  for j in range(N):
    if 10000*i + 5000*j + 1000*(N-i-j) == Y:
      a = i
      b = j
      c = N-i-j
if a == 0 and b == 0 and c == 0:
  print(-1,-1,-1)
else:
  print(a,b,c)
N,Y = map(int,input().split())
flag = False
ans = ""
for x in range(N + 1):
  if flag:
    break
  for y in range(N - x, N + 1):
    if x + y > N or flag:
      break
    for z in range(N - x - y, N + 1):
      if x + y + z > N or flag:
        break
      if x * 10000 + y * 5000 + z * 1000 == Y:
        ans = str(x) + " " + str(y) + " " + str(z)
        flag = True
if flag:
  print(ans)
else:
  print("-1 -1 -1")
n ,y = map(int,input().split())
list = {}
for i in range(n):
    for j in range(n - i):
        for k in range(n - i - j):
            if (i*10000 + j * 5000 + k* 1000) == y:
                list = [i,j,k]
if len(list) == 0:
    list = [-1,-1,-1]
print(list[0],list[1],list[2])
N, Y = map(int, input().split())
flag = 0
for x in range(N+1):
    if flag == 0:
        for y in range(N-x+1):
            if (10000*x + 5000*y + 1000*(N-x-y) == Y) and (N-(x+y))>=0:
                flag = 1
                break
    else:
        break

if flag ==1:
    print(x-1, y , N-(x-1+y))
else:
    print('-1 -1 -1')
N, Y = map(int, input().split())

answer = (-1,-1,-1)
for a in range(N):
    
    for b in range(N):
        
        c = N -a -b
            
        total = a*10000 + b*5000 + c*1000 
        if (total == Y) and (a+b+c==N) and (c>=0):
            answer = (a, b, c)
            break
        
print(*answer)
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):
        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())
flag = False
for x in range(N):
    for y in range(N - x):
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            print(x, y, N - x - y)
            flag = True
            exit()
if (not flag): print("-1 -1 -1")
n,y=map(int,input().split())
t=0
flag=True

for x in range(n+1):
    for y in range(n+1):
        z=n-x-y
        if x+x+z==y:
            print(x,y,z)
            flag=False
if flag:
    print(-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:
            arr.append([i,j,k])

if len(arr) >0:
    print(arr[0][0],arr[0][1],arr[0][2])
else:
    print(-1,-1,-1)
N,Y = [int(x) for x in input().split()]
Y = Y // 1000
for y in range(N):
  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")
from sys import stdin
n,y = map(int,stdin.readline().rstrip().split())
for i in range(n+1):
    for j in range(n-i,n+1):
        k = n-(i+j)
        if k < 0:
            continue
        elif 10000*i+5000*j+1000*k == y:
            print(i,j,k)
            exit()
print(-1,-1,-1)
n, y = map(int,input().split())
r1,r2,r3 = -1,-1,-1
for f in range(n):
    for h in range(n):
        if 10000 * f + 5000 * h + 1000 *( n-(f + h)) == y:

            r1,r2,r3 = f, h, n-(f + h)
            break

print(str(r1) + ' ' + str(r2) + ' ' + str(r3))
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):
            for z in range(n+1-x-y):
                curr = 10000 * x + 5000 * y + 1000 * z
                if curr != 0 and curr == target:
                    return str(x) + ' ' + str(y) + ' ' + str(z)
    return '-1 -1 -1'


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

for i in range(N):
  for j in range(N):
    a = i
    b = j
    c = N-i-j
    if c < 0:
      continue
    else:
      price = a*1000+b*5000+c*10000
      if price == Y:
        print(c,b,a)
        exit()
print(-1,-1,-1)
N, Y = map(int, input().split())

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

print(-1, -1, -1)
n, y = map(int, input().split())
d = y - 1000*n
a = d // 9000
ab = []
for i in range(a+1):
  d2 = d - 9000*i
  b = d2 // 4000
  for j in range(b+1):
    d3 = d2 - 4000*j
    if d3 == 0:
      ab.append(i)
      ab.append(j)
if len(ab) == 0:
  print(-1,-1,-1)
else:
  c = n - ab[0] - ab[1]
  if c >= 0:
    print(ab[0], ab[1], c)
  else:
    print(-1,-1,-1)
import sys
sys.setrecursionlimit(10**6)
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
N, Y = ri_()
for i in range(N):
    for j in range(N):
        if 1000 * (N - i - j) == Y - 10000 * i - 5000 * j and N - i - j >= 0:
            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):
    z = n - x - y
    if 10000*x + 5000*y +1000*z == Y and 0<=z<=2000:
      print('{} {} {}' .format(x, y, z))
      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+1):
    if i+j>0:
      continue
    h=n-i-j
    if 10000*i+5000*j+1000*h==y:
      a,b,c=i,j,h
      break

print("{} {} {}".format(a,b,c))
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("{0} {1} {2}".format(i, j, (n - i - j)))
            exit(0)
    print("-1 -1 -1")
n, Y = map(int,input().split())
ans = 0

flag = False
for y in range(n+1):
    for x in range(n+1):
        z = int((Y- 5000*y - 10000*x)/1000)
        if 0 < z + y + x <= n and 0 <= z:
            print(x, y, z)
            flag = True
            break
        elif x == n:
            print(-1, -1, -1)
            flag = True
            break
    if flag:
        break
n,y  = list(map(int,input().split()))

if y/n > 10000:
  print('-1 -1 -1')
elif y < n*1000:
  print('-1 -1 -1')
else:
  for a in range(y//10000 +1):
    for b in range(y//5000 +1):
      if n-a-b >= 0:
        if 10*a + 5*b + (n-a-b) == (y/1000):
          print(*[a,b,n-a-b])
          exit()

print('-1 -1 -1')
try:
    N, Y = map(int, input().split())
    cnt = 0
    for x in range(N):
        for y in range(N):
            z = N-x-y
            if z>=0 and 10000*x+5000*y+1000*z==Y:
                cnt += 1
                print(x,y,z)
                break
    if cnt==0:
        print('-1 -1 -1')
except EOFError:
    pass
N, Y = map(int, input().split())

for x in range(N, -1, -1):
    for y in range(N-x, -1, -1):
        for z in range(N-x-y, -1, -1):
            if (10000*x)+(5000*y)+(1000*z) == Y:
                print(x, y, z)
                exit()
            
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
            if n-a-b>=0:
                print(a,b,n-a-b)
                break
    else:
        print(-1,-1,-1)
import sys
n, y = map(int, input().split())
x = y//10000

for a in list(reversed(range(x+1))):
    for b in range((y-10000*a)//5000):
        c = n - a - b
        if 10000*a + 5000*b + 1000*c == y:
            print('{0} {1} {2}'.format(a,b,c))
            sys.exit()
print('-1 -1 -1')
N,Y = map(int,input().split())
flg = False
a=0
b=0
c=0
for x in range(N+1):
    for y in range(N+1):
        for z in range(N+1):
            if 10000*x + 5000*y + 1000*z == Y:
                a = x
                b = y
                c = z
                flg = True
                break
if flg == True:
    print(a,b,c)
else:
    print(-1,-1,-1)
N, Y = map(int, input().split())
result = None
for i in range(N+1):
    if result is not None:
        break
    for j in range(i+1):
       total = 10000 * (N-i) + 5000 * (i-j) + 1000 * j
       if (total < Y):
            result =  "%s %s %s" % (-1,-1,-1)
            break
       elif (total == Y):
            result = "%s %s %s" % (N-i, i-j, j)
            break
       else:
            continue
print(result)
n, Y = map(int, input().split())
fin = True
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)
            fin = False
            break
if fin:
    print('-1 -1 -1')
N,Y = map(int,input().split())
target = Y - 1000*N
a,b,c =-1,-1,-1
for i in range(N+1):
    target_x = target - 4000*i
#    print(target_x)
    if target_x < 4000:
        break
    if target_x % 9000 == 0:
        a = int(target / 9000)
        b = i
        c = N - a - b
        break
print(*[a,b,c])
N, Y = map(int, input().split())
isFound = False
for x in range(N):
    if isFound:
        break
    for y in range(N):
        z = N-x-y
        if (10000*x+5000*y+1000*z==Y)&(z>=0):
            print('{} {} {}'.format(x,y,z))
            isFound = True
            break
if isFound == False:
    print('-1 -1 -1')
N, Y = map(int,(input().split()))
a = Y // 10000
Y = Y - (a * 10000)
b = Y // 5000
Y = Y - (b * 5000)
c = Y // 1000

if a + b + c <= N:
    print(str(a) + ' ' + str(b) + ' ' + str(c))

else:
    print('-1 -1 -1')
n,y=map(int, input().split())
y=y//1000
for i in range(1+y//10):
	if i>n:
		pass
	for j in range(1+(y-10*i)//5):
		if i+j>n:
			pass
		if y==10*i+5*j+(n-i-j):	
			print(i,j,n-i-j)
			exit()

print(y//10000)
n, y = map(int, input().split())

for a in range(n+1):
    for b in range(n+1):
        for c in range(n+1):
            
            if(1000*a + 5000*b + 10000*c == 45000):
                print(c, b, a)
                quit()
N,Y = map(int,input().split())
f = 0

for x in range(2001):
    for y in range(2001):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y and z >= 0:
            print(x,y,z)
            f = 1
            break
if f == 0:
    print('-1','-1','-1')
n,y=map(int,input().split())
flag=True

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)
            flag=False
            break

if flag==False:
    print(-1,-1,-1)
N, SUM = map(int,input().split())
X=10000
Y=5000
Z=1000
ans = [-1, -1, -1]
for x in range(SUM//X+1):
    for y in range(SUM//Y+1):
        rest = SUM-x*X-y*Y
        if rest % 1000 == 0:
            ans = [x, y, rest//Z]
            if sum(ans)==N:
                break
            else:
                ans = [-1,-1,-1]
                
print(*ans)
n, y = map(int, input().split())
ans1 = -1
ans2 = -1
ans3 = -1
for i in range(n):
    for j in range(n):
        if 10000*i + 5000*j + (n-(i+j))*1000 == y:
            ans1 = i
            ans2 = j
            ans3 = n-(i+j)
            break
print(ans1, ans2, ans3)
N, Y = map(int, input().split())


x = -1
y = -1
z = -1
if Y%1000 == 0:
  Y = Y//1000
  n = (Y-N)//9
  for i in range(1,n+1):
    if ((Y-N)-9*i)%4==0 and (Y-N)>=9*i and N>=i+((Y-N)-9*i)//4:
      x = i
      y = ((Y-N)-9*i)//4
      z = N-x-y
print(x,y,z,sep=' ')
N, Y = map(int, input().split())

result = []
for a in range(N+1):
  for b in range(N+1):
    for c in range(N+1):
      total = a * 10000 + b * 5000 + c * 1000
      if total == Y:
        result.append([a, b, c])

if len(result) == 0:
  print("0 0 0")
else:
  print(" ".join(map(str, result[0])))
n, y = map(int, input().split())
for i in range(n + 1):
	if 1000 * i > y:
		break
	for j in range(n + 1):
		k = n - (i + j)
		if 1000*i + 5000*j + 10000*k > y or k < 0 or k > 2000:
			break
		if 1000*i + 5000*j + 10000*k == y:
			print(k, j, i)
			exit()
print("-1 -1 -1")
N,Y=map(int,input().split())
num=0
for x in range(N):
    for y in range(N):
        for z in range(N):
            if x+y+z==N and 10000*x+5000*y+1000*z==Y:
                print(x,y,z)
                break
            else:
                num+=1

if num==N**3:
    print(-1,-1,-1,sep=" ")
N,Y = map(int,input().split())
s=0
for x in range(2000):
  for y in range(2000):
    z = N - (x+y)
    if 1000*x + 5000*y + 10000*z == Y:
      print(x,' ',y,' ',z)
      s = s+1
    else:
      continue
  break
if s == 0:
  print(-1,' ',-1,' ',-1)
N , Y = (int(x) for x in input().split())
senen = Y//10000
result = False
gosenen = Y // 5000

for x in range(N, -1, -1):
    #Y = Y - 10000 * x
    #print("x:",x)
    for y in range(N,-1,-1):
        #Y = Y - y * 5000
        z = N - x - y
        if x * 10000 + y * 5000 + z * 1000 == Y and x + y + z <= N:
            result = True
            print(x,y,z)
            break
    else:
        continue
    break





if result == 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):
        rest = y - 10000*i - 5000*j
        if rest / 1000 == n-i-j:
            print(i, j, n-i-j)
            count += 1
        break
if count == 0:
    print(-1,-1,-1)
N,Y=map(int,input().split())
s=0
for x in range(0,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())
x = 0
y = 0
z = n

s = [(0, 0, n)]
while len(s) > 0:
  x, y, z = s.pop()
  if 10000*x+5000*y+1000*z == y:
    print(x, y, z)
    exit()
  else:
    if z > 0:
      s.append((x+1, y, z-1))
      if x-y > 1:
        s.append((x, y+1, z-1))
print("-1, -1, -1")
N,Y=map(int,input().split())

xyz=[]
for x in range(N):   
    for y in range(N-x):
        z=N-(x+y)
        total=10000*x+5000*y+1000*z
        if (total==Y)&(x+y+z==N):
            xyz.append([x,y,z])
if xyz:
    print(xyz[0])
else:
    print([-1,-1,-1])
n ,y = map(int,input().split())
list = [-1,-1,-1]
for i in range(n+1):
    for j in range(n+1 - i):
        for k in range(n + 1 - i - j):
            if (i * 10000 + j * 5000 + k* 1000) == y:
                list = [i,j,k]
    if sum(list) > 0:
        break
print(list)
from sys import stdin
import sys

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

 
if __name__ == "__main__":
    solves()
N,Y=map(int,input().split())
for i in range(N+1):
  for j in range(N+1-i):
    for k in range(N+1-i-j):
      if i*10000+j*5000+k*1000==Y:
        print(i,j,k)
        exit()
else:
  print("{0} {1} {2}".format(-1,-1,-1))
N, Y = map(int, input().split())


found = False
for i in range(N+1):
    for j in range(N+1):
        k = (Y - 10000*i + 5000*j) // 1000
        if i + j + k == N and k >= 0:
            print(i, j, k)
            found = True
            break
    if found:
        break

if not found:
    print(-1, -1, -1)
n,Y = map(int,input().split())
Y = int(Y / 1000)
ans = [-1,-1,-1]
for x in range(n):
    for y in range(n):
        if 10*x + 5*y + (n-x-y) == Y and n-x-y >= 0:
            ans = [x,y,n-x-y]
print(*ans)
n, y = map(int, input().split())
j=True
if y % 1000 != 0 or y // 10000 > n:
    print(-1, -1, -1)

for th in range(0, n+1) :
    for fh in range(0, n-th+1) :
        if th * 10000 + fh * 5000 + (n-fh-th) * 1000 == y :
            print (th, fh, n-fh-th)
            j = False
            break
    else :
        continue
    break
if j == True:
    print(-1, -1, -1)
n,y=map(int,input().split())
f=0
for i in range (n+1):
    if f==1:
        break
    for j in range(n+1):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y:
            print("{} {} {}".format(i,j,k))
            f=1
n, y = map(int, input().split())
res10000 = -1
res5000 = -1
res1000 = -1
for i in range(n):
    for j in range(n-i):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            res10000 = i
            res5000 = j
            res1000 = k
            break
print(res10000, res5000, res1000)
n,y = map(int,input().split())


i5000 = 0
i10000 = 0
N = n + 1
for i1000 in range(N):
    for i5000 in range(N - i10000):
        i10000 = n - i1000 - i5000
        sum = i10000*10000 + i5000*5000 + i1000*1000
        if sum == y:
            print(i10000,i5000,i1000)
            exit()
print("-1 -1 -1")
N,Y = map(int,input().split())
f = 0

for x in range(2001):
    for y in range(2001):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y and z > 0:
            print(x,y,z)
            f = 1
            break
if f == 0:
    print('-1','-1','-1')