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

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

print(-1, -1, -1)
"""
tuple
"""
n,Y = map(int,input().split())
ans = -1,-1,-1
for x in range(n+1):
    for y in range(n-x+1):
        z = n - x - y 
        if 0 <= z <=2000 and (10000*x+5000*y+z*1000)==Y:
            ans = x,y,z
            break
        else :
            continue
        break
print(*ans)
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 and N-(x+y) >= 0:
            print(x, y, N-(x+y))
            exit()
 
print(-1,-1,-1)
N, Y = map(int, input().split())

ans = [-1, -1, -1]
for i in range(Y//1000+1):
    for j in range(Y//5000+1):
        k = (Y - 10000*i - 5000*j)//1000
        if k < 0:
            break
        if i + j + k == N:
            ans = i, j, k
# print(10000*ans[0] + 5000*ans[1] + 1000*ans[2])
print(*ans)
N, Y = map(int, input().split())
flag = False
for x in range(N + 1):
    for y in range(0, N - x + 1):
        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")
import math
n,y = map(int,input().split())
c = 0
for a in range(n+1):
	for b in range(n+1):
		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())
y //= 1000
for i in range(n+1):
    p,q = divmod(y-n-i,4)
    if q == 0 and i <= p-i <= n:
        print(i,p-2*i, n-p+i)
        exit()
print("-1 "*3)
import sys
input = sys.stdin.readline
N, Y = map(int, input().split())
Y //= 1000
for i in range(N + 1):
  x = Y - 10 * i
  for j in range(N - i + 1):
    y = x - 5 * j
    if y < 0: continue
    if i + j + y == N:
      print(i, j, y)
      exit(0)
  if x + i == N:
    print(i, 0, x)
    exit(0)
print(-1, -1, -1)
N,Y = map(int,input().split())
array = []
for i in range(N+1):
    for j in range(N+1-i):
        mon = 10000*i+5000*j+1000*(N-i-j)
        if mon == Y:
            print(i,j,N-i-j)
            exit()
print('-1 -1 -1')
N, Y = map(int, input().split())

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

if len(result) == 0:
  print("-1 -1 -1")
else:
  print(" ".join(map(str, result[0])))
n,y = map(int, input().split())

def Otoshidama(n):
    for i in range(0, y//10000 + 1):
        for j in range(0, (y - 10000*i)//5000 + 1):
            h = y - 10000*i - 5000*j
            if h%1000 == 0 and h >= 0 and i + j + h//1000 == n:
                return str(i) + " " + str(j) + " " + str(h//1000)
    return "-1 -1 -1"

print(Otoshidama(n))
n, y = map(int, input().split())
ans = ''
for i in range(n + 1):
  for j in range(n + 1 - i):
    k = n - i  - j
    if 10000 * i + 5000 * j + 1000 * k == y:
      ans = f'{i} {j} {k}'
      break
  if ans:
    break
print(ans if ans else '-1 -1 -1')
n,m = map(int,input().split())
total = 0

for a in range(n+1):
  for b in range(n+1):
    total=10000*a+5000*b+1000*(n-a-b)
    if total == m and a+b <=n:
      print(a,b,n-a-b)
      exit()
    
print(-1,-1,-1)
n,y = map(int, input().split())
a = -1
b = -1
c = -1

for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if k < 0:
            pass
        else:
            yy = 10000*i + 5000*j + 1000*k
            if yy == y:
                a = i
                b = j
                c = k
                break
print(a,b,c)
N, Y = map(int, input().split())

match = False
for a in range(N+1):
    for b in range(N+1):
        c = N - (a + b)
        y = 10000*a + 5000*b + 1000*c
        if c >= 0 and y == Y:
            match = True
            break
    if match:
        break

if match:
    print(a, b, c)
else:
    print(-1, -1, -1)
N, Y = map(int, input().split())
Y2 = Y // 1000
mod5 = Y2 % 5
div5 = Y2 // 5
for c_div5 in range(div5 + 1):
    c = c_div5 * 5 + mod5
    a = (Y2 - c) // 5 - (N - c)
    b = N - a - c
    if a >= 0 and b >= 0: break
    if c_div5 == div5: a=-1;b=-1;c=-1
print(a, b, c)
def main():
    N, Y = map(int,input().split())
    x, y, z = [0, 0, 0]
    
    for i in range(N + 1):
        for j in range(N + 1 - i):
            if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y and N-i-j >= 0:
                print(i, j , N-i-j)
                return
    
    print(-1, -1, -1)

if __name__ == "__main__":
    main()
a,b=map(int,input().split())
t=b/1000
List=[-1,-1,-1]
for l in range(a+1):
    if (t-9*l-a)%4==0 and a-l-(t-9*l-a)/4>=0 and t-9*l-a>=0:
        s=int((t-9*l-a)/4)
        List=[l,s,a-l-s]
        break
print(*List)
n , y = map(int, input().split())

i = y//10000
j = y//5000
k = y//1000

for p in range(i+1):
  for q in range(j+1):
    if (n-p-q)>=0 and (p*10000)+(q*5000)+((n-p-q)*1000)==y:
      print(p, q, n-p-q)
      exit()
    
print(-1, -1, -1)
N, Y = map(int,input().split())
x, y, z = -1, -1, -1
k = 0
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 :
            x, y, z = i, j, k
            break
print(x, y, z)
import sys
n, ans = map(int, input().split())

for x in range(n + 1):
    for y in range(n + 1 - x):
        if n - x - y >= 0:
            if (10000 * x + 5000 * y + 1000 * (n - x - y)) == ans:
                print(x, y, n - x - y)
                sys.exit()

print('-1 -1 -1')
N,Y = [int(i) for i in input().split()]
for i in range(N+1):
    for j in range(N-i, -1, -1):
        money = i*10000 + j*5000 + (N - i - j)*1000
        if money == Y:
            print(i,j,N-i-j)
            exit()
        elif money < Y:
            break
print(-1,-1,-1)
n, t = map(int, input().split())
sen = -1
gos = -1
man = -1
for i in range(n+1):
    for j in range(n-i+1):
        if i * 1000 + j*5000 + (n-i-j)*10000 == t:
            sen = i
            gos = j
            man = n-i-j
print(man, gos, sen)
n,y = list(map(int,input().split()))
y /= 1000
ans = [0,0,0]
# print(y)
for i in range(n+1):
    for j in range(0,n+1-i):
        a = i*10 + j*5
        b = i+j
        # print(a,b)
        if a + (n-(i+j)) == y:
            ans = [i,j,n-(i+j)]

if sum(ans) >0:
    print(ans[0],ans[1],ans[2])
else:
    print(-1,-1,-1)
n, k = map(int, input().split())
for x in range(n+1):
    for y in range(n+1):
        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")
def ans(N, Y):
    for m in range(N + 1):
        for g in range(N + 1 - m):
            s = N - m - g
            sum = m * 10000 + g * 5000 + s * 1000
            if sum == Y:
                return m, g, s
    return -1, -1, -1

def read():
    N, Y = [int(a) for a in input().split(' ')]
    return N, Y

def write(a):
    print(a[0], a[1], a[2])

if __name__ == '__main__':
    N, Y = read()
    write(ans(N, Y))
#!/usr/bin/env python3
import sys
n, y = map(int, input().split())

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

        if (i * 10000) + (j * 5000) + ((k) * 1000) == y:
            print(i, j, k)
            sys.exit()

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

if not flag:
    print(-1, -1, -1)
n, y = map(int, input().split())
judge = "no value"

for i in range(n+1):
    if judge == "Found it!":
        break
    for j in range(n+1):
        z = n - i - j
        value = z * 10000 + i * 5000 + j *1000
        if value == y and z >= 0:
            print(z, i , j)
            judge = "Found it!"
            break

if judge == "no value":
    print(-1, -1, -1)
n, y = map(int, input().split())

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

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

ans = [-1, -1, -1]
ok = False
for x in range(N+1):
    for y in range((N+1)-x):
        if 10000 * x + 5000 * y > Y:break
        z = N - x- y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()
if not ok: print(-1, -1, -1)
import sys
input = sys.stdin.readline

def main():
    N, Y = map(int, input().split())
    ans = "-1 -1 -1"
    for i in range(N+1):
        for j in range(N+1-i):
            if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
                ans = "{} {} {}".format(i, j, N-i-j)
                break
        if ans != "-1 -1 -1":
            break
    print(ans)

if __name__ == '__main__':
    main()
N, Y = map(int,input().split())
for i in range(N + 1):
  for j in range(N - i + 1):
    if Y == 1000*i + 5000*j + 10000*(N - j - i):
      print(N - j - i, j, i)
      exit(0)
print(-1,-1,-1)
def solve(N,Y):
    for x in range(N+1):
        for y in range(N-x+1):
            z = N-(x+y)
            if(10*x + 5*y + z == Y):
                print("{} {} {}".format(x,y,z))
                return 0

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

solve(N,Y)
n, y = map(int, input().split())

stop = n + 1
for m in range(stop):
    for g in range(stop - m):
        s = n - m - g
        if y == 10000 * m + 5000 * g + 1000 * s:
            print(m, g, s, sep=" ")
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")
#Nはお札の枚数、Yは合計金額
N,Y = map(int,input().split())

yukiti = 10000
higuti = 5000
noguti = 1000
re_yukiti = -1
re_higuti = -1
re_noguti = -1

for i in range(N+1):
    for j in range(N+1-i):
        k = N - i - j
        amount = yukiti*i + higuti*j + noguti*k
        if amount == Y:
            re_yukiti = i
            re_higuti = j
            re_noguti = k
            break

print(re_yukiti,re_higuti,re_noguti)
n,y = map(int,input().split())
f = False
for a in range(n+1):
    for b in range(n+1):
        c = n-(a+b)
        if 10000*a+5000*b+1000*c == y and a+b+c == n and c>= 0:
            f = True
            print(a,b,c)
    if f == True:
        break
if f == False:
    print('-1 -1 -1')
#085_C
n,y=map(int,input().split())
for a in range(0,n+1):
    mon=y-10000*a
    cnt=n-a
    
    if (mon-1000*cnt)%4000==0 and (5000*cnt-mon)%4000==0:
        b=(mon-1000*cnt)//4000
        c=(5000*cnt-mon)//4000
        
        if 0<=b<=n and 0<=c<=n:
            print(a,b,c)
            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 N-i-j < 0:
                continue
            if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y:
                print(i, j, (N-i-j))
                return 
    print(-1, -1, -1)

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

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

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

    print(-1, -1, -1)


if __name__ == '__main__':
    resolve()
#!/usr/bin/env python

def main():
    N, Y = list(map(int, input().split()))
    for i in range(N+1):
        for j in range(N-i+1):
            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()
n, yen = map(int, input().split())
for x in range(n + 1):
    for y in range(n - x + 1):
        z = n - x - y
        if yen == x * 10000 + y * 5000 + z * 1000:
            print(x, y, z)
            exit(0)
print("-1 -1 -1")
n,y = map(int,input().split())
res = [-1,-1,-1]
for i in range(n+1):
    for j in range(n-i+1):
        if(10000*i + 5000*j + 1000*(n-i-j) == y):
            res = [i,j,n-i-j]
            break
                
print(*res)
n,y = map(int,input().split())
ans = [0]*3
for i in range(n+1):
    for j in range(n+1):
        if i*10000 + j*5000 + (n-i-j)*1000 == y and (n-i-j) >= 0:
            print(i,j,n-i-j)
            exit()
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-i+1):
        k = n - i - j
        if i * 10 + j * 5 + k == y / 1000:
            ans = [i, j, k]
            print(i, j, k)
            exit()
ans = [str(a) for a in ans]
print(' '.join(ans))
n,y = [int(e) for e in 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)
            break
    else:
        continue
    break
else:
    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 1000*i+5000*j+10000*k == Y:
            print(k, j, i)
            exit(0)
print(-1, -1, -1)
N, Y = map(int, input().split())

for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j):
            print(i, j, N-i-j)
            break
    else:
        continue
    break
else:
    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==i*10000+j*5000+(N-i-j)*1000):
            print('{i} {j} {k}'.format(i=i,j=j,k=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):
        ans=10000*(N-i-j)+5000*j+1000*i
        if ans==Y:
            print(N-i-j,j,i)
            exit()
print(-1,-1,-1)
N, Y = map(int, input().split())

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

str_ans = map(str, ans)
print(" ".join(str_ans))
n,y=map(int,input().split())
c=0
for i in range(n+1):
    for j in range(n-i+1):
        if 9*i+4*j+n==y//1000:
            print(i,j,n-i-j)
            c=1
            break
    if c==1:
        break
if c!=1:
    print(-1,-1,-1)
N, Y = map(int, input().split())

total = 0
for a in range(N+1):
    
    for b in range(N+1-a):
        
        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)
N,Y = map(int, input().split())

for x in range(2001):
    for y in range(2001):
        z = N-x-y
        if z<0:
            break
        temp = x*10000+y*5000+z*1000
        if temp==Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)
a,sums= list(map(int,input().split()))
yuki = sums//10000
taishi = (sums%10000) //5000
noguchi = (sums%5000) //1000
while a>yuki+taishi+noguchi:
  if ((a-(yuki+taishi+noguchi))%4==0)&(taishi>0):
    taishi-=1
    noguchi+=5
  elif yuki>0:
    yuki-=1
    taishi+=2
  else:
    break
if a==yuki+taishi+noguchi:
  print(yuki,taishi,noguchi)
else:
  print("-1 -1 -1")
def main():
    N,Y = map(int,input().split())
    for i in range(Y//10000+1):
        for j in range(N-i+1):
            if Y == i *10000 + j * 5000 + (N-i-j) * 1000:
                print(*[i,j,N-i-j])
                return
    print(*[-1,-1,-1])
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, Y = map(int, input().split())
for x in range(n+1):
  for y in range(n-x+1):
    z = n-x-y
    if 0 <= z <= n and 10000*x+5000*y+1000*z == Y:
      print(x,y,z)
      exit()
print(-1,-1,-1)
n, y = map(int, input().split())
count = 5000*n
work = [0, n, 0]
for i in range(n):
    if y > count:
        count += 5000
        work[0] += 1
        work[1] -= 1
    elif y < count:
        work[2] += 1
        work[1] -= 1
        count -= 4000
    else:
        break
if y == count:
    print(" ".join(map(str, work)))
else:
    print("-1 -1 -1")
N,Y = map(int,input().split())
for i in range(min(N+1,Y//10000 + 1)):
    for j in range(N+1-i):
        if 10000 * i + 5000 * j + 1000 * (N-i-j) == Y:
            print(i,j,N-i-j)
            exit(0)
print(-1,-1,-1)
n, t = map(int, input().split())

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

print("-1 -1 -1")
N , Y = map(int,input().split())
k = 0
for i in range(N+1):
  x = i
  for j in range(N - i + 1):
    y = j
    if (Y - x * 10000 - y*5000)/1000 == N - x - y >=0 :
      print(str(x) +' '+str(y)+' '+str(N-x-y))
      k = 1
      break
  if k == 1:
    break
if k== 0:
  print('-1 -1 -1')
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0 <= z <= 2000 and 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 - x + 1):
        z = N - x - y
        if x*10000+y*5000+z*1000 == Y:
            print(x, y, z)
            exit()


print("-1 -1 -1")
N, Y =map(int, input().split())
X = [-1,-1,-1]
for i in range(2001):
  y = (Y-1000*N-9000*i)/4000
  if not float.is_integer(y):
    continue
  if 0<= N-i-y <= 2000 and 0<= y <= 2000:
    X=[i, y, N-i-y]
    X=list(map(int, X))
    break
print(*X)
N, Y = map(int, input().split())
a = 0
b = 0
c = 0
for i in range(N+1):
    for j in range(N+1):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y and N-i-j>=0:
            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())

res=(-1,-1,-1)

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

for i in range(N+1):
    A = i
    for j in range(N+1):
        B = j
        C = N - A - B
        if C < 0:
            break
        s = 10000*A+5000*B+1000*C
        if s == Y:
            a = str(A)
            b = str(B)
            c = str(C)
            print(a+" "+b+" "+c)
            exit()

print("-1"+" "+"-1"+" "+"-1")
N, Y = map(int, input().split())
a = min(Y // 10000, N) + 1
for i in range(a):
  b = min((Y - (10000 * i)) // 5000, N - i) + 1
  for j in range(b):
    if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
      print(i, j, N - i - j)
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')
N,Y = map(int, input().split())
for i in range(N+1):
    for j in range(N-i+1):
        if 10000*i + 5000*j + 1000*(N-(i+j)) == Y:
            print(i,j,(N-(i+j)))
            exit()
print(-1,-1,-1)
N,Y = map(int,input().split())
res = (-1,-1,-1)
for x in range(N+1):
  for y in range(N+1-x):
    if N-x-y >=0 and 10000*x + 5000*y + 1000*(N-x-y) == Y:
      res = (x,y,N-x-y)
print(res[0],res[1],res[2])
N,Y=(int(x) for x in input().split())
# YY現在の金額
# n:使える枚数
F=0
Y=Y/1000
for i in range(N+1):
    for j in range(N+1-i):
        if (Y-10*i-5*j)==(N-i-j):
            print(i,j,N-i-j)
            F=1
        else:
            continue
    if F==1:break
    

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 - i, -1, -1):
        if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
            ans[0] = i
            ans[1] = j
            ans[2] = (N - i - j)

print(*ans)
N, Y = map(int, input().split())
res10000 =res5000 = res1000 = -1

for x in range(N+1):
    for y in range(N+1-x):
        z = N-x-y # zは決まっているので、ループを減らして、計算量を減らす！
        if 10000*x + 5000*y + 1000*z == Y:
            res10000 = x
            res5000 = y
            res1000 = z

print(res10000, res5000, res1000)
N, Y = map(int, input().split(' '))

for man in range(N+1):
    for go in range(N-man+1):
        if (10000*man+5000*go+1000*(N-man-go)) == Y:
            print('{} {} {}'.format(man, go, N-man-go))
            exit()

print('{} {} {}'.format(-1, -1, -1))
n, y = (int(x) for x in input().split())
ans = 0
m = y // 10000 + 1
for i in reversed(range(m)):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            ans = [i, j, n-i-j]
            break
    if ans != 0:
        break
if ans == 0: print(*[-1, -1, -1])
else: print(*ans)
import sys
N, Y = map(int, input().split())
for i in range(N + 1):
    if 10000 * i > Y:
        break
    for j in range(N + 1 - i):
        if 10000 * i + 5000 * j > Y:
            break
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k > Y:
            break
        if 10000 * i + 5000 * j + 1000 * k == Y:
            print('{0} {1} {2}'.format(i, j, k))
            sys.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 10000*i + 5000*j + 1000*(n-i-j) == y:
            print(i, j, n-i-j)
            exit()

print(-1, -1, -1)
def judge(n, s):
    for x in range(n, -1, -1):
        for y in range(n - x, -1, -1):
            if 10000 * x + 5000 * y + 1000 * (n - x - y) == s:
                return str(x) + " " + str(y) + " " + str(n - x - y)
    return "-1 -1 -1"

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

print(judge(n, s))
N, Y = map(int, input().split())

man = -1
gosen = -1
sen = -1

for i in range(N+1):
  for j in range(N+1):
    k = N-i-j
    if Y == i*10000+j*5000+k*1000 and k >= 0:
      print(i, j, k)
      exit()
      
print(-1, -1, -1)
import sys
N,Y = map(int,input().split())
for x in range(min(N,Y//10000)+1):
    for y in range(min(N-x,(Y-10000*x)//5000)+1):
        z = N-x-y
        if 10000*x+5000*y+1000*z == Y:
            print(x,y,z)
            sys.exit()
print(-1,-1,-1)
N, Y = [int(str) for str in input().strip().split()]
Y //= 1000

for i in range(N + 1):
    for j in range(N - i + 1):
        k = N - i - j
        if 10 * i + 5 * j + 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-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+1-i):
    if y==i*10000+j*5000+(n-i-j)*1000:
      print(i,j,(n-i-j))
      exit()
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):
      z = n - i - j
      if i * 10000 + j * 5000 + z * 1000 == y:
        print(i, j, z)
        exit()
  print('-1 -1 -1')
  
if __name__ == '__main__':
  main()