peterverebics/CodeNet_Python_118 huggingface dataset:
# -*- coding: utf-8 -*-

n, Y = map(int,input().split())
x , y , z = '-1' , '-1' , '-1'

def check(num,total):
  for i in range(num+1):
    for j in range(num+1):
      k = num - i - j
      if (i + j + k == num) and (10000 * i + 5000 * j + 1000 * k == total):
        x , y , z = str(i) , str(j) , str(k)
        return x + ' ' + y + ' ' + z
res = check(n,Y)
if res is None:
  res = x + ' ' + y + ' ' + z
print(res)
N,Y = map(int, input().split())
ans= [-1, -1, -1]

for x in range(N+1):
    for y in range(N-x+1):
        price = x*10000 + y*5000 + int(N-x-y)*1000
        if price == Y:
            print(x,y,N-x-y)
            break
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 resolve():
    N, Y = map(int, input().split())
    if Y % 1000 != 0 or Y > 10000 * N:
        print("-1 -1 -1")
        return
    b10k = Y // 10000
    Y -= b10k * 10000
    b5k = Y // 5000
    Y -= b5k * 5000
    bk = Y // 1000
    print("-1 -1 -1") if b10k + b5k + bk > N else print(b10k, b5k, bk)


if __name__ == "__main__":
    resolve()
billNum, Declation = map(int, input().split())
bill10000 = -1
bill5000  = -1
bill1000  = -1

for x in range(billNum + 1):
    for y in range(billNum + 1):
        z = billNum - x - y
        sumOfMoney = x * 10000 + y * 5000 + z * 1000
        if Declation == sumOfMoney:
            bill10000 = x
            bill5000  = y
            bill1000  = z
            break

print(bill10000, bill5000, bill1000)
N,Y = map(int,input().split())
a,b,c =-1,-1,-1
if Y<=10000*N:    
    target = Y - 1000*N
    for i in range(N+1):
        target_x = target - 4000*i
        if target_x < 4000:
            break
        if target_x % 9000 == 0:
            #print(target_x)
            a = int(target_x / 9000)
            b = i
            c = N - a - b
            break
print(*[a,b,c])
n, yen = list(map(int, input().split()))

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

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

print("-1,-1,-1")
N,Y=map(int,input().split())
for i in range(N+1):
  for k in range(N+1-i):
    m = N-i-k
    if 10000*i + 5000*k + 1000*m == Y:
      print(i,k,m)
      exit()
print('-1' '-1' '-1')
N, Y = map(int, input().split())
for x in range(N):
  for y in range(N-x):
    z = N - x - y
    if z > 0 and 10000*x + 5000*y + 1000*z == Y:
      print(str(x)+" "+str(y)+" "+str(z))
      exit()
print("-1 -1 -1")
n,y = map(int,input().split())
for a in range(2001):
  for b in range(2001):
    c = n - a - b
    if 10000*a + 5000*b + 1000*c == y and 0 <= c <= 2000:
      print(str(a) + " " + str(b) + " " + str(c))
    break
n,y=map(int,input().split())

flag=0
total = 0
flag = 0


for i in range(n+1):
    for j in range(n+1):
        k=n-i-j
        if k<0:
            break

        total=10000*i-5000*j+1000*k
        if total==y:
            print(i,j,k)
            flag=1
            break 
    if flag == 1:
        break

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

def main():
  if Y % 1000 != 0:
    print("-1 -1 -1")
    return
  cnt = Y // 1000
  if 10000 * cnt < N:
    print("-1 -1 -1")
    return
  for i in range(N):
    for j in range(N):
      for k in range(N):
        if i + j + k != N:
          continue
        if Y == 10000 * i + 5000 * j + 1000 * k:
          print("%i %i %i".format(i, j, k))

if __name__ == "__main__":
  main()
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 9000*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=map(int, input().split())

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

print('-1 -1 -1')
a,b=map(int,input().split())
c,d,e=10000,5000,1000
for i in range(a):
  for j in range(a):
    for k in range(a-i-j):
      if i*c+j*d+k*e==b:print(i,j,k)
else:print(-1,-1,-1)
N, Y = map(int, input().split())

res = False

a = 0
b = 0
c = 0

for i in range(N + 1):
    for q in range(N + 1):
        c = N - (i + q)
        total = 10000*i + 5000*q + 1000*c
        if total == Y:
            res = True
            a = i
            b = q
            d = c

if res:
    print('{} {} {}'.format(a, b, d))
else:
    print('-1 -1 -1')
N, Y = map(int, input().split())

out = '-1 -1 -1'
for x in range(N):
	for y in range(N):
		z = N - x - y if N - x - y >= 0 else 0
		total = 10000 * x + 5000 * y + 1000 * z
		if total == Y:
			out = '{} {} {}'.format(x, y, z)
			break
print(out)
import sys
n, y = map(int, input().split())

for i in range(n):
    for j in range(n - i):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            sys.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):
        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 = 0

t = int(y/10000)
y -= t*10000

f = int(y/5000)
y -= f*5000

h = int(y/1000)
y -= h*1000

if t+f+h != n or y != 0:
    print("-1 -1 -1")
else:
    print(t,f,h)
N,Y=map(int,input().split())
ans=-1,-1,-1
for i in range(N+1):
    for j in range(N+1):
            if 1<=N-i-j<=2000 and 10000*i+5000*j+1000*(N-i-j)==Y:
                ans=i,j,N-i-j
print(*ans)
N, Y = map(int, input().split())
for x in range(N+1):
  for y in range(N-x):
    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())

cond = 0
for a in range(N):
	
	for b in range(N):
		res = Y-10000*a-5000*b
		if res < 0:
			continue
		s,t = divmod(res,1000)
		if (0 <= s) and (a+b+s == N) and (t == 0):
			cond = 1
			break
	if cond:
		break
if cond:
	print(a,b,s)
else:
	print('-1 -1 -1')
N = 1000
Y = 1234000
##N,Y = map(int,input().split())

ans = -1,-1,-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:
            ans = x,y,z
            break
        else:
            break

print(*ans)
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 == 0 and (i+j) == a:
      k = 0
      flag = 1
      break
    elif nokori%10000 == 0 and nokori >= 0:
      k = int(nokori/10000)
      if (i+j+k)==a:
        flag = 1
        break
    
      
  if flag == 1:
    break
if flag == 1:
  print(k,j,i)
else:
  print("-1 -1 -1")
N, Y = map(int, input().split())

# 合計値
y = 0

# 正解組み合わせがあった場合
exist_answer = False

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

if exist_answer is False:
    print(-1, -1, -1)
#!/usr/bin/env python3

def main():
    n, y = map(int, input().split())

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


if __name__ == "__main__":
    main()
otoshidama = list(map(int,input().split()))
flg = True
while flg:
    for i in range(otoshidama[0]+1):
        yukichi =i
        for n in range(otoshidama[0]-yukichi+1):
            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")
N, Y = [int(i) for i in input().split()]

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

if len(ans) == 0:
    print(-1 -1 -1)
else:
    print(ans[0][0], ans[0][1], ans[0][2])
N, Y = map(int, input().split())

total = 0
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):
            print(a, b, c)
            exit()
        
print(-1,-1,-1)
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())
A = B = C = -1
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:
            A = a
            B = b
            C = c
            
print(a, b, c)
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N+1 - x):
        if x * 10000 + y * 5000 + (N - x - y) * 1000 == Y:
            print(x, y, (N - x - y))
            exit()
print("-1 - 1 - 1")
n, y = map(int, input().split())
for i in range(n+1):
  for g in range(n-i):
    s = n-i-g
    if 10000*i + 5000*g + 1000*s == y:
      print(i, g, s)
      exit()
print('-1 -1 -1')
N, Y = map(int, input().split())

res = False

a = 0
b = 0
c = 0

for i in range(N + 1):
    for q in range(N + 1):
        c = N - (i + q)
        if c > 0 and i > 0 and q > 0:
            total = 10000*i + 5000*q + 1000*c
            if total == Y:
                res = True
                a = i
                b = q
                d = c

if res:
    print('{} {} {}'.format(a, b, d))
else:
    print('-1 -1 -1')
n,y=map(int,input().split())
flag=True

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

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

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

def f():
    for i in range(N+1):
        for j in range(9):
            k = N-i-j
            if i*10000+j*5000+k*1000 == Y:
                print(i, j, k)
                return

    print(-1,-1,-1)

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


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


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


if not isOK:
    print(-1, -1, -1)
n,y=map(int,input().split())
if 1000*n > y:
    print(-1,-1,-1)
amari=y-1000*n

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-x-y)
            break
else:
    print(-1,-1,-1)
n, k = map(int, input().split())
for x in range(n):
    for y in range(n):
        if x + y <= n:
            z = n - x - y
            result = 10000*x + 5000*y + 1000*z
            if result == k:
                print("{} {} {}".format(x, y, z))
                exit()
print("-1 -1 -1")
import sys

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

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

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

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

if check==0:
    yu = -1
    hi = -1
    no = -1

print(str(yu) + " " + str(hi) + " " + str(no))
def otoshidama():
    N, Y = map(int,input().split())
    for i in range(N):
        for j in range(N - i):
                if Y == 1000*i + 5000*j + 10000*(N - j - i):
                    print(N - j - i, j, i)
                    return
    print(-1,-1,-1)
    return
otoshidama()
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if y==10000*i-5000*j-1000*(n-i-j):
            print(i,j,n-i-j)
            exit()
print(-1,-1,-1)
n, result = map(int, input().split())
 
for x in range(n + 1):
  for y in range(n - x + 1):
    if x + y + (n - x - y) == 9:
      if 10000 * x + 5000 * y + 1000 * (n - x - y) == result:
        print(x, y, (n - x - y))
        exit()
 
print("-1 -1 -1")
N, Y = list(map(int, input().split()))

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

if ans == 0:
    print(-1, -1, -1)
else:
    print(ans)
N,Y = map(int,input().split())
x = 0
y = 0
z = 0
flag = False
for i in range(N+1):
  for j in range(N+1):
    if int((Y-10000*i-5000*j)/1000) == N-i-j:
      x = i
      y = j
      z = N-i-j
      flag = True
      break
    break
if flag == False:
  print(-1,-1,-1)
else:
  print(x,y,z)
N, Y = map(int, input().split())
ans = [-1 -1 -1]
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 and (x+y+z) == N:
                ans = [x, y, z]
                break
print(*ans)
N, Y = map(int, input().split())
 
for x in range(N+1):
  for y in range(N+1-x):
        if x*10000 + y*5000 + (N+1-x-y)*1000 == Y:
           print(x, y, N+1-x-y)
           exit()

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

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

main()
n,s = map(int, input().split())

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

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

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

    print(-1 -1 -1)

main()
N, Y = map(int, input().split())
flag = 1

for i in range(N+1):
    for j in range(N+1):
        if Y == i * 10000 + j * 5000 + (N-i-j) * 1000 and flag == 1:
            print("{} {} {}".format(i, j, N-i-j))
            flag = 0

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

if 10000 * N < Y:
    print(-1, -1, -1)

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

print("-1 -1 -1")
import sys
inf = 10**15
mod = 10**9+7
n, y = map(int, input().split())
ans=0
A = y//10000
for i in range(A+1):
    restY = y-i*10000
    restN = n-i
    if restY >= 0 and restN >= 0:
        B = restY//5000
        for j in range(B+1):
            restY = restY-j*5000
            restN = restN-j
            if restN>=0 and restY == restN*1000:
                print('{} {} {}'.format(i,j,restN))
                sys.exit()
print('{} {} {}'.format(-1,-1,-1))
n,y = map(int,input().split())
y = y // 1000

for a in range(n+1):
    rest = y - a * 10
    if rest < 0:break
    for b in range(n+1):
        rest = rest - b * 5
        c = n - a - b
        if rest < 0:break
        if rest == c:
            print(a,b,c);exit()
print(-1,-1,-1)
N, Y=map(int,input().split())#二つの数字をペアで入力。この時スペース区切りでInt型に変換
ans = -1,-1,-1

for i in range(N+1):
    for j in range(N):
        if i*10000 + j*5000 + (N-i-j)*1000 == Y: #肝となる判定ロジック
            print(i, j, N-i-j)
            exit()

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:
            print(N-y-z, y, z)
            sys.exit()

print(-1, -1, -1)
N,Y = map(int,input().split())
for x in range(N,-1,-1):
    print(x)
    for y in range(N,-1,-1):
        print(y)
        for z in range(N,-1,-1):
            print(z)
            if 10000*x+5000*y+1000*z == Y:
                print(x,y,z)
                break
        else:
            continue
        break
    else:
        continue
    break
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 Y == 10000*x + 5000*y + 1000*z:
				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-i
            break
print(n10, n5, n1)
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 - a +1):
        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 = map(int, input().split())
for i in range(n):
    for j in range(n):
        k = y-(i*10000 + j*5000)
        if k >= 0:
            k = k // 1000
            if i + j + k == n:
                print(i, j, k)
                exit()
print(-1, -1, -1)
N, Y = map(int, input().split())
res = False
for i in range(N + 1):
    for q in range(N + 1):
        c = N - i - q
        total = 10000*i + 5000*q + 1000*c
        if total == Y:
            res = True
            a = i
            b = q
            d = c
if res:
    print('{} {} {}'.format(a, b, d))
else:
    print('-1 -1 -1')
n, y = map(int, input().split())
for i in range(1, n+1):
  for j in range(1, n+1):
    if ( i*10000 + j*5000 + (n-i-j)*1000 ) == y:
      print(i,j,(n-i-j))
      exit()
    if i+j+1 == n:
      break
print('-1 -1 -1')
n,y= map(int,input().split())
ans=0
for i in range(n+1):
  for j in range(n-i,n+1):
    z=y-i*10000-j*5000
    if 0<=z/1000<n and z % 1000 == 0:
      print(i,j,z/1000)
      exit()
print(-1,-1,-1)
a = list(map(int, input().split()))
x = -1
y = -1
z = -1
for i in range(a[0]):
    for j in range(a[0]-i):
        b = 10000*i + 5000*j + 1000*(a[0]-(i+j))
        if b == a[1]:
            x = i
            y = j
            z = a[0]-(i+j)
            break
    else:
        continue
    break
print(i, end=" ")
print(j, end=" ")
print(a[0] - (i + j))
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(' '))
a = False
for i in range(0, n+1):
    for i2 in range(0, n-i):
        c = n - i2 - i
        if i*10000 + i2 * 5000 + c * 1000 == y:
            print (i, i2, c)
            a = True
if a == False:
    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())
for i in range(0,n+1):
    for j in range(0,n+1-i):
        k=n-i-j
        if y==10000*i+5000*j+1000*k:
            print(i,j,k)
        break
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if y==10000*i-5000*j-1000*(n-i-j):
            print(i,j,n-i-j)
            exit()
print("-1,-1,-1")
n,y=map(int,input().split())
ans=[]
flag=False
for i in range(0,n):
  for j in range(0,n):
    if (9000*i+4000*j)==(y-1000*n) and n>=(i+j):
      ans=[i,j,n-i-j]
      flag=True
      break
if flag:
  print(*ans)
else:
  print(-1,-1,-1)
n,y = map(int,input().split())

ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n+1-i):
        #for k in range(n+1-i-j):
        d = y - (i * 10000 + j * 5000)
        if d >= 0 and d % 1000 == 0 and d//1000 <= n - i - j:
            ans = '{} {} {}'.format(i,j,d//1000)
            break
print(ans)
N, Y = map(int, input().split())

for ykt in range(0, N+1):
    for icy in range(0, N+1):
        hdy = N - ykt - icy
        if 10000 * ykt + 5000 * icy + 1000 * hdy:
            print(str(ykt) + ' ' + str(icy) + ' ' + str(hdy))
            exit()

print('-1 -1 -1')
import sys

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

for a in range(N+1):
    for b in range(N-a):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            print(a,b,c)
            sys.exit()

print("-1 -1 -1")
import collections
import sys

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

q = collections.deque([10000] * n)
s = sum(q)

while len(q) != 0:
    if s == y:
        c = collections.Counter(q)
        print("%d %d %d" % (c.get(10000, 0), c.get(5000,0), c.get(1000,0)))
        sys.exit()
    if s < y:
        break

    tmp = q.popleft()
    if tmp == 10000:
        s -= 5000
        q.appendleft(5000)
    elif tmp == 5000:
        s -= 4000
        q.append(1000)

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

"""
a #10,000円
b #5,000円
c #1,000円
"""
ans = []

for a in range(N):
    for b in range(N):
        c = N - a - b
        if 10000*a + 5000*b + 1000*(N-a-b) == Y:
            print(a,b,N-a-b)
            exit()
print(-1,-1,-1)
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
            if 10000*i+5000*j+1000*(n-i-j)==y:
                print(i,j,n-i-j)
                exit()
print("-1,-1,-1")
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, y  = map(int, input().split())
#s = list(str(input()))
#n = int(input())

max1 = int(y/1000) + 1

for i in range(max1):
  rest = y-i*9000-n*1000
  mod = rest%4000
  if(mod == 0 and rest>0):
    ii  = int((rest)/4000)
    iii = n-i-ii
    print(i, ii, iii)
    sys.exit()

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

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