peterverebics/CodeNet_Python_118 huggingface dataset:
N,Y = map(int,input().split())
flag = 0
for x in range(1,N+1):
    for y in range(N-x+1):
        z_m = Y-(10000*x+5000*y)
        z_n = N-x-y
        if z_m >=0 and z_m//1000 == z_n:
            print(x,y,z_n)
            flag=1
            break
    else:
        continue
    break
if flag == 0:
    print(-1,-1,-1)
n,y = map(int,input().split())

for i in range(n):
    for j in range(n-i):
        if 1000*i+5000*j+10000*(n-i-j) == y:
            print(n-i-j, j, i)
            exit()
print(-1, -1, -1)
n, result = 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) == result:
      print(x, y, n - x - y)
      exit()
 
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 i*10000 + j*5000 + k*1000 == y and k >= 0:
            print(i, j, k)
            flag = False
        break

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

for a in range(N + 1):
    for b in range(N + 1):
        c = N - (a + b)
        if isinstance(c, float) or c < 0:
            continue
        if Y == 10000*a + 5000*b + 1000*c:
            print(a,b,c)
            break
         

print('-1 -1 -1 ')
n, y = map(int, input().split())
t = 0
for i in range(n):
    if t == 1:
        break
    for j in range(n):
        if (i+j) <= n:
            if i * 1000 + j * 5000 + (n - i - j) * 10000 == y:
                print((n - i - j), j, i)
                t = 1
                break


if t == 0:
    print(-1, -1, -1)
n,y=[int(x) for x in input().split()]
import sys
for i in range(n+1):
    for j in range(n+1-i):
        for k in range(n+1 - (i+j)):
            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())
c = 0
for n in range(N+1):
    if c == 1:
        break
    for m in range(N-n):
            l = N -n - m
            if Y ==( n*10000 + m *5000 + l *1000) and (n + m + l) == N:
                print(n , m , l)
                c = 1
                break
if c != 1:
    print(-1 , -1 , -1)
otoshidama = list(map(int,input().split()))
flg = True
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
            break

if flg:
    print("-1 -1 -1")
N,Y = list(map(int,input().split()))

flag = False
for x in range(2001):
    for y in range(2001):
        if 10000*x + 5000*y + 1000*(N-(x+y)) == Y and (N-(x+y)) >= 0:
            print(x,y,N-(x+y))
            flag = True
            break
        else:
            break
if flag == False:
    print(-1,-1,-1)
a,b = map(int,input().split())
for i in range(a+1):
    for j in range(a+1):
        z = a-i-j
        if 10000*i+5000*j+1000*z==b and 1<=z<=2000:
            print(i,j,z)
            exit()
print(-1,-1,-1)
n,y=map(int,input().split())
if y>10000*n:
    print("-1 -1 -1")
else:
    for i in range(n+1):
        print(i)
        for j in range(n-i+1):
            if y==10000*i+5000*j+(n-i-j)*1000:
                print(i,j,(n-i-j))
                exit()
print("-1 -1 -1")
import sys
num, price = map(int,sys.stdin.readline().rstrip().split())
for x in range(num+1):
  for y in range(num-x+1):
    sum = x *1000 + y * 5000 + (num-x-y) * 1000
    if sum == price:
      print(x, y, num-x-y)
      sys.exit()
print(-1,-1,-1)
import sys
n, y = map(int, input().split())

max_yukiti = y // 10000
flag = False
for i in range(max_yukiti + 1):
    for j in range(n+1):
        k = n - i - j
        # print(i,j,k)
        if k < 1:
            break
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i,j,k)
            sys.exit()
if ~flag:
    print(-1,-1,-1)
N,Y=map(int,input().split())
ans=0
for x in range (N):
    for y in range(N):
        if 10000*x+5000*y+1000*(N-x-y)==Y:
            print(x,y,N-x-y)
            exit()
print(-1,-1,-1)
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,y = iim()
for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        v = 10000*i+5000*j+1000*k
        if k > 0 and v == y:
            print(i,j,k)
            exit()
print(-1,-1,-1)
n, y = map(int, input().split())

hasuu = n % 5

exist = False
for sen in range(hasuu, n):
    for gosen in range(n):
        man = n - gosen - sen
        if man < 0:
            break
        if y == man * 10000 + gosen * 5000 + sen * 1000:
            exist = True
            break
    if exist:
        break
if exist:
    print('{} {} {}'.format(man, gosen, sen))
else:
    print('-1 -1 -1')
n, sum = 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 == sum:
                break
        else:
            continue
        break
    else:
        continue
    break
else:
    x, y, z = -1, -1, -1


print("{} {} {}".format(x, y, z))
m = input().split()
N = int(m[0])
Y = int(m[1])
ans = [0] * 3

for a in range(N+1):
  for b in range(N - a + 2):
    c = N - (a + b)
    money = (a * 10000) + (b * 5000) + (c * 1000)

    if money == Y:
      ans[0] = a
      ans[1] = b
      ans[2] = c
      break
  else:
    continue

  break

if ans == [0, 0, 0]:
  ans = [-1, -1, -1]

x = ans[0]
y = ans[1]
z = ans[2]

print(str(x) + ' ' + str(y) + ' ' + str(z))
n, y = map(int, input().split())

def fun(n, y):
    for i in range(y//10000):
        for j in range(y//5000):
            k = (y - 10000*i - 5000*j)//1000
            if i + j + k == n:
                return (i, j, k)

    return (-1, -1, -1)
import sys
#N枚のお金N，合計金額Y
N, Y = map(int, input().split())

a = 0 #1000円札の枚数
b = 0 #5000円札の枚数
c = 0 #10000円札の枚数

X = 0 #合計金額

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


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

for i in range(n+1):
  for j in range(i, n+1):
    res = y - (10000*i + 5000*j)
    if (res == 1000*(n - i - j)) and ((n - i - j)>=0):
      print(i, j, n-i-j)
      exit()
      
print('-1 -1 -1')
n,Y=map(int,input().split())
cnt=0
for x in range(n+1):
  for y in range(n+1):
    s=Y-10000*x-5000*y
    z=s//1000

    if z>=0 and z<=n:
      print('{} {} {}'.format(x,y,z))
      cnt+=1
      break
if cnt==0:
  print('{} {} {}'.format(-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+1):
        k = n-i+j
        if 10000*i+5000*j+1000*k == y:
            print(i,j,k)
            exit()
print(-1,-1,-1)
all = list(map(int, input().split()))

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

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

print(yu)
print(" ")
print(hi)
print(" ")
print(no)
print(" ")
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
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x,y,z)
        break
else:
    print(-1,-1,-1)
N, Y = map(int, input().split())

resx, resy, resz = (-1, -1, -1)
xmax = min(N, Y//10000)
for x in range(xmax+1):
    ymax = (Y - 10000*x)//5000
    for y in range(ymax+1-x):
        z = N - x - y
        total = 10000*x + 5000*y + 1000*z

        if total == Y:
            resx, resy, resz = (x, y, z)
            break

print(resx, resy, resz)
from itertools import *
N,Y = map(int,input().split())
man,gosen,sen = 0,0,0
for i in range(N):
  for j in range(N-i):
    k = N-i-j
    for xyz in combinations([i,j,k],3):
      x,y,z = xyz
      if 10000*x + 5000*y + 1000*z == Y:
        # print(10000*x + 5000*y + 1000*z)
        print(x,y,z)
        exit()
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):
        for k in range(n+1):
            if i+j+k==n:
                if 10000*i+5000*j+1000*k==y:
                    print("{} {} {}".format(i,j,k))
                    f=1
import math
N,Y = map(int, input().split())

breakRoop = False

for x in range(N):
  for y in range(N-x):
    z = N-x-y
    total = x*1000 + y*5000 + z*10000
    if total == Y:        
      print(x, y, z)
      breakRoop = True
      break
  if breakRoop:
    break

if not breakRoop:
  print(-1, -1, -1)
N, Y = map(int, input().split())        
Anser = [-1, -1, -1]

flag = False

for i in range(N+1):
    if flag == True: break
    for j in range(N+1):
        if flag == True: break
        for k in range(N+1):
            if flag == True: break
            if Y == 10000*i + 5000*j +1000*k:
                Anser =[i, j, k]
                flag = True

print(*Anser)
N,Y = list(map(int,input().split()))
Y = Y // 1000
A = Y // 10
B = Y - A*10
C = B // 5
D = B - C*5
ans = A+C+D
if ans == N:
  print('{0} {1} {2}'.format(A,C,D))
  exit()
for i in range(0,A+1):
    for j in range(0,C+1):
        answer = ans + i*9 + j*4 
        if answer == N:
          print('{0} {1} {2}'.format(A-i,C-j,D+i*10+j*5))
          exit()
print('-1 -1 -1')
N,Y = map(int,input().split())
flag = False
for i in range(N):
    y = int(Y/4000-9*(i+1)/4-N/4)
    x = N - (i+1) - y
    if (x >=0) & (y >= 0) & (x*1000 + y*5000 +(i+1)*10000 == Y):
        print('{0} {1} {2}'.format(i+1 ,y,x ))
        flag = True
        break


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

result = []
for a in range(N+1):
  for b in range(N+1):
    c = N - a - b
    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())
sum = 0
for i in range(N):
	for j in range(N):
		for k in range(N):
			if(((i+j+k<=N) and k*1000+j*5000+i*10000)==Y):
				flag = True
				print(k,j,i)
				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-=1
    noguchi+=5
  else:
    yuki-=1
    taishi+=2
if a==yuki+taishi+noguchi:
  print(yuki,taishi,noguchi)
else:
  print("-1 -1 -1")
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        yen=0
        k=n-i-j
        if k>0:
            yen=10000*i+5000*j+1000*k
            if yen==y:
                print(i,j,k)
                exit()
print(-1,-1,-1)
n,y = map(int, input().split())
err = '-1 -1 -1'

for i in range(n+1):
    for j in range(n+1-i):
        if y == 10000 * (n+1-i-j) + 5000 * j + 1000 * i:
            ans = str(n-i-j) + " " + str(j) + " " +  str(i)
            break
        else:
            ans = err
    # 以下,多重ループを抜ける手法。
    else:
        continue
    break

print(ans)
N, Y = list(map(int, input().split()))
results = [-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 Y == 10000 * x + 5000 * y + 1000 * z:
            results = [x, y, z]
            print(results)
            exit()
print(results)
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)
      exit()
      
print("-1 -1 -1")
n , y = map(int,input().split())
y = y//1000
m = 0
for i in range(y//10+1):
    y1 = y-10*i - n +i
    if y1%4 == 0 and n-i-y1//4>=0:
        print(i,y1//4,n-i-y1//4)
        exit()
print('-1 -1 -1')
main_list = input().split()
n = int(main_list[0])
y = int(main_list[1][:-3])

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

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

no = -1

for o in range(n):
    for f in range(n):
        if 10000*n - 9000*o -5000*f == y:
            print(n-o-f , f , o)
            exit(0)
        
print(no , no , no)
n, X = map(int, input().split())
 
for i in range(n+1):
  for j in range(n+1):
    if i+j > n:
      pass
    else:
      k = n-i-j
      otoshi = 10000*i + 5000*j + 1000*k
      if otoshi == X:
        print(i, j, k)
        break
  else:
    continue
  break
def resolve():
    N, Y = map(int, input().split())

    resx, resy, resz = (-1, -1, -1)
    n = min(N, Y//10000)
    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 == Y:
                resx, resy, resz = (x, y, z)
                break
    
    print(resx, resy, resz)
    
resolve()
import math
N,Y = map(int, input().split())

breakRoop = False

for x in range(N):
  for y in range(N-x):
    for z in range(N-x-y):
      total = x*1000 + y*5000 + z*10000
      if total == Y:        
        print(x, y, z)
        breakRoop = True
        break
    if breakRoop:
      break
  if breakRoop:
      break
      
if not breakRoop:
  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):
        if y == i*10000 + j*5000 + (n-i-j)*1000:
            print(" ".join(list(map(str,[i,j,n-i-j]))))

print("-1 -1 -1")
n,y = map(int,input().split())
z= y//1000
if z != y/1000:
  print(-1,-1,-1)
  exit()
  
for i in range(n+1):
  for j in range(n+1-i):
    for k in range(n+1-i-j):
      if 10*i + 5*j + k == z:
        print(i,j,k)
        exit()
      elif 10*i + 5*j + k > z:
        print(-1,-1,-1)
        exit()
n, y = map(int, input().split())

ans = 0
for x in range(n+1):
  for p in range(n+1-x):
    z = n - x - p
    if y-10000*x-5000*p == 1000*z and x+p+z == n:
      print(x, p, z)
      ans += 1
    break

if ans == 0:
  print(-1, -1, -1)
N, Y = map(int, input().split())
if Y % 1000 != 0:
    print(-1, -1, -1)
else:
    # max(N)=2000 -> 2000**2 = 4*(10**6)
    for a in range(N):
        for b in range(N):
            c = N - a - b
            if c < 0:
                continue
            elif Y == 10000 * c + 5000 * b + 1000 * a:
                print(c, b, a)
                exit()
    print(-1, -1, -1)
N,Y = map(int,input().split())

change = False

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)
            change = True
        else:
            break
            
if change != True:
    print("-1 -1 -1")
n, y = map(int, input().split())

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

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

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

is_exist = False

for i_m in range(man_max+1):
  for i_g in range(gosen_max+1):
    if 99000*i_m + 4000*i_g == Y - 1000*N:
      print(i_m, i_g, int(Y / 1000 - 10*i_m - 5*i_g))
      is_exist = True
      break
      
if not is_exist:
  print(-1, -1, -1)
N, Y = map(int, input().split())

q = -1
w = -1
r = -1

for a in range(N + 1):
    for b in range(N + 1):
        c = N - a - b
        # if a > 0 and b > 0 and c > 0:
        total = 10000*a + 5000*b + 1000*c
        if total == Y:
            q = a
            w = b
            r = c

print('{} {} {}'.format(q, w, r))
N, Y = map(int, input().split())

q = Y//1000 - N

x = [0, 4, 8, 3, 7, 2, 6, 1, 5]

b = x.index(q%9)
c = (q - 4*b) // 9
a = N-c-b

if a<0 or Y%1000 != 0:
    print(-1, -1, -1)
else:
    print(c, b, a)
def main():
  ans = [-1, -1, -1]
  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 == Y and a + b + c == N:
          ans = [a, b, c]
  print(*ans)
if __name__ == "__main__":
  main()
n,y=map(int,input().split())
n+=1
if y>10000*n:
    print("-1 -1 -1")
else:
    for i in range(n):
        for j in range(n-i):
            for g in range(n-i-j):
                if y==10000*i+5000*j+g*1000:
                    print(i,j,g)
                    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) & (i+j+k==9):
            print(i,j,k)
            exit()
print('-1 -1 -1')
n, result = map(int, input().split())

for x in range(n + 1):
  for y in range(n + 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 = map(int,input().split())
x = 0
y = 0
z = 0
flag = False
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
      flag = True
      break
    break
if flag == False:
  print(-1,-1,-1)
else:
  print(x,y,z)
N, Y = map(int, input().split())
cnt = 0
for x in range(1, N + 1):
    for y in range(1, N + 1):
        if x * 10000 + y * 5000 + (N - x - y) * 1000 == Y:
            cnt += 1
            
print(cnt)
n, y = map(int, input().split())
a = y // 10000
x = y % 10000
b = x // 5000
c = (x % 5000) // 1000
print((f"-1 -1 -1", f"{a} {b} {c}")[a + b + c <= n])
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())
for x in range(Y//10000+1):
    for y in range((Y - (10000*x))//5000+1):
        z = (Y - (10000*x) - (5000*y))//1000
        if x + y + z == N:
            print(x, y, z)
            exit()
        if x + y + z > N:
            break
else:
    print(-1, -1, -1)
N, Y = map(int, input().split())
Y //= 1000

if 10*N < Y or N > Y:
  print('-1 -1 -1')
  
for a in range(N+1):
  for b in range(N-a+1):
    if Y - 10*a - 5*b == N - a - b:
      c = N - a - b
      print('{} {} {}'.format(a,b,c))
      exit()
      
print('-1 -1 -1')
a, b = map(int, input().split())
count = 0
for i in range(a+1):
  for j in range(a+1):
      c = a - (i+j)
      s = (10000*i + 5000*j + 1000*c)
      if b == s:
        count+=1
        break
  else:
    continue
  break
if count == 0:
  print(-1,-1,-1)
else:
  print(i,j,c)
N, Y = map(int, input().split())
for a in range(0, 10):
    for b in range(0, N - a + 1):
        c = N - a - b
        if (10000 * a + 5000 * b + 1000 * c) == Y:
            print(a, b, c)
            exit()
print(-1, -1, -1)
N, Y = map(int, input().split())

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

for i in range(N+1):
    for j in range(N+1):
        if 10000*i + 5000*j + 1000*(max(N-i-j, 0)) == Y:
            x = i
            y = j
            z = N - (i+j)
            break

print(x, y, z)
def main():
    N, Y = (int(i) for i in input().split())
    for i in range(N+1):
        for j in range(N+1):
            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 = list(map(int, input().split()))

ans = [-1,-1,-1]

for a in range(N+1):
        for b in range(N+1-a):
                c = N - a - b;
                total = 10000 * a + 5000 * b + 1000 * c
                if total == Y:
                        ans = [ a , b , c ]

print(ans)
import sys

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

for i in range(N):
    for j in range(N-i):
        k = N-i-j
        ans = i*10000 + j*5000 + k*1000

        if ans == Y:
            print("{0} {1} {2}" .format(i,j,k))
            sys.exit()

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

satu = [1000,5000,10000]

sen = [1000 * i for i in range(n+1)]
gsen = [1000 * i for i in range(n+1)]
man = [10000 * i for i in range(n+1)]

for i in range(n+1):
    for j in range(n+1-i):
        if man[i]+ gsen[j] + sen[n-i-j] == y:
            print(i,j,n-i-j)
            exit()

print("-1 -1 -1")
n, y = map(int, input().split())
a = 0
a += (y%5000)//1000
n -= a
y -= a*1000
if n*10000>=y and y>=n*1000:
  if y>= 5000*n:
    m = (y-5000*n)//5000
    print(m,n-m,a)
  else:
    m = y-1000*n
    for i in range(n//2+1):
      m2 = m
      m2 -= 9000*i
      if m2%4000 == 0:
        j = m2//4000
        print(i,j,n-i-j+a)
        exit(0)
    print(-1,-1,-1)        
else:
  print(-1,-1,-1)
N, Y = map(int, input().split())
Y //= 1000
p = [-1, -1, -1]
for i in range(N):
  for j in range(N - i):
    if 9 * i + 4 * j == Y - N:
      p = [i, j, N - i - j]
print(p[0], p[1], p[2])
n,y=map(int, input().split())
count = 0
for i in range(n):
  for j in range(n-i):
    k = int((y - (i * 10000) - (j * 5000))/1000)
    if i + j + k == n and (i * 10000) + (j * 5000) + (k * 1000) == y:
      print(i, j, k)
      count += 1
      break;
    break;
if count == 0:
  print(-1, -1, -1)
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
            exit()

print(*ans)
n, y = map(int, input().split())

f = False

for i in range(y // 10000 + 1):
    for j in range((y - 10000 * i) // 5000 + 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")
# coding: utf-8
# Your code here!
n,y = map(int,input().split())
total = 0
for i in range(n + 1):
    total += i * 10000
    for j in range(n - i + 1):
        total += j * 5000 
        total += (n - i - j) * 1000
        if total == y:
            print(i ,j ,n-i-j)
            exit()
        total = 0
print(-1,-1,-1)
n,y=map(int,input().split())

for i in range(n+1):
  for j in range(i,n+1):
    k=n-i-j
    if k>=0 and i*10000+j*5000+k*1000==y:
      print(i,j,k)
      exit()
print(-1,-1,-1)
# https://atcoder.jp/contests/abc085/tasks/abc085_c

# N枚、Y円
N, Y = map(int, input().split())

for i in range(N + 1):
    for j in range(N + 1):
        
        z = N - (i + j)

        if z < 0:
            continue

        total = i*1000 + j*5000 + z*10000
        
        if total == Y:
            print(i, j, z)
            exit()

print('-1 -1 -1')
def main():
    n, y = map(int, input().split())
    five, y1 = divmod(y, 10000)
    four, y2 = divmod(y1, 5000)
    three, y3 = divmod(y2, 1000)
    print(five, four, three, sep=' ') if y3 == 0 else print(-1, -1, -1)

if __name__ == "__main__":
    main()
N,Y = map(int,input().split())
for i in range(N):
  for j in range(N):
    for k in range(N):
      if (10000*i + 5000*j + 1000*k == Y) and (i + j + k == N):
        print(i,j,k,end=' ')
        break