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

ans = []

for i in range(n+1):#1000円
    for j in range(n+1-i):#5000円
        val = 1000 * i + 5000 * j + 10000 * (n-i-j)
        if val == y:
            ans.append(n-i)
            ans.append(j)
            ans.append(i)
            break

if ans:
    print(*ans[0:3])
else:
    print(-1,-1,-1)
N, Y = 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)
A=10000
B=5000
C=1000
ans_A=-1
ans_B=-1
ans_C=-1
x,y=map(int,input().split())
for a in range(x+1):
  for b in range(x-a+1):
    for c in range(x-a-b+1):
      if a*A+b*B+c*C==y:
        ans_A=a
        ans_B=b
        ans_C=c
print(ans_A,ans_B,ans_C)
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:
                print(i,j,k)
                exit()
print(-1,-1,-1)
N, Y = map(int, input().split())

for i in range(N+1):
    for j in range(N+1-i):
        k = N-i-j
        m = 10000*i+5000*j+1000*k
        if m == Y:
            print("%s %s %s" % (i, j, k))
            break
        else:
            continue

print("-1 -1 -1")
n,y = map(int,input().split())
for a in range(n):
    for b in range(n):
        c = n - a - b
        if 10000*a + 5000*b + 1000*c == y and a + b + c == n:
                print(a,b,c)
                exit()
print(-1,-1,-1)
n,s=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+y+z==s:
            print(x,y,z)
            flag=False
            break
if flag:
    print(-1,-1,-1)
n, y = map(int, input().split())
ans=[]
for i in range(n):
    for j in range(n):
        if i+j<n:
            k=n-i-j
        else:
            k=0
        if 10000*i+5000*j+1000*k==y:
            ans+=i,j,k
            break
    else :
        continue
    break

if len(ans)==0:
    ans+=-1,-1,-1

print(ans[0],ans[1],ans[2])
import sys

num = sys.stdin.readline().split(' ')
N = int(num[0])
Y = int(num[1])


for x in range(N+1):
    for y in range(N+1):
        if 10000 * x + 5000 * y + 1000*(N-x-y) == Y:
            print(str(x)+' '+str(y)+' '+str(N-x-y))
            sys.exit()
        else:
            continue

print('-1 -1 -1')
x = list(map(int, input().split()))
ans = 0
man = 0
gosen = 0
sen = 0
for i in range(x[0]+1):
  for j in range(x[0]+1-i):
    if i*10000+j*5000+(x[0]-i+j)*1000 == x[1]:
      man = i
      gosen = j
      sen = x[0]-i+j
      ans = 1
      break
if ans == 1:
  print(str(man)+' '+str(gosen)+' '+str(sen))
else:
  print('-1 -1 -1')
n,y=map(int,input().split())
a=int(y/10000)
b=int((y-a*10000)/5000)
if (y-a*10000-b*5000)%1000 == 0:
	print(a,b,int((y-a*10000-b*5000)/1000))
else:
	print(-1,-1,-1)
import sys
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)
            sys.exit()
print(-1,-1,-1)
m = input().split()
N = int(m[0]) + 1
Y = int(m[1])
ans = [0] * 3

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

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

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

print(str(x) + ' ' + str(y) + ' ' + str(z))
temp = input().split()
n,total = int(temp[0]), int(temp[1])
a,b,c = 0,0,0

for i in range(n):
    if (a+1)*10000 <= total:
        a += 1
    else:
        break
    
for i in range(n):
    if a*10000 + (b+1)*5000 <= total:
        b += 1
    else:
        break

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

ans = []

for i in range(n+1):#1000円
    for j in range(n+1-i):#5000円
        val = 1000 * i + 5000 * j + 10000 * (n-i-j)
        if val == y:
            ans.append(i)
            ans.append(j)
            ans.append(n-i-j)
            break

if ans:
    print(*ans[0:3])
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 i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
      print(i, j, n - i - j)
      exit()

      print("-1 -1 -1")
import itertools

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

t = (1000, 5000, 10000)
l = list(itertools.combinations_with_replacement(t, n))

for i in range(len(l)):
    if sum(l[i]) == y:
        print(l[i].count(10000), l[i].count(5000), l[i].count(1000))
        exit()
n, y = map(int, input().split())

#.
ans = 0

#.
for i in range(n+1):
    for j in range(n+1):
        #.
        money = y - i*10000 - j*5000

        #.
        if money % 1000 != 0:
            continue

        #.
        if money / 1000 <= n - i - j:
            ans += 1

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

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

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

flag=False

for i in range(N+1):
  for j in range(N+1):
    if(9000*i+4000*j==Y-1000*N):
      flag=True
      x=i
      y=j
      z=N-i-j
      
if(flag!=True):
  print("-1 -1 -1")
else:
  print(str(x)+" "+str(y)+" "+str(z))
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())
a = -1
b = -1
c = -1
for i in range(N):
  for j in range(N-i):
    if i*9000 + j*4000 == Y - 1000*N:
      a = i
      b = j
      c = N-i-j
print(a, b, c)
n, Y = map(int,input().split())
ans = 0

flag = False
for x in range(n+1):
    for y 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+1:
            print(-1, -1, -1)
            flag = True
            break
    if flag:
        break
N, Y = map(int, input().split())
x, y, z = -1, -1, -1

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

for i10000 in range(n):
  for i5000 in range(n):
    i1000 = (y - (i10000*10000 + i5000*5000)) // 1000
    if i1000 + i5000 + i10000 == n:
      print(i10000, i5000, i1000)
      exit()

print('-1 -1 -1')
N, Y = map(int, input().split())
Y /= 1000
flag = False
for i in range(N+1):
    if flag:
        break
    for j in range(N+1):
        if Y - 10 * i - 5 * j == N - i - j:
            flag = True
            print(i, j, N-i-j)
        else:
            break
if flag == False:
    print(-1,-1,-1)
n,y = map(int,input().split())
ans = '-1 -1 -1'

for i in range(n):
	for j in range(n-i+1):
		if y == i*10000 + j*5000 + (n-i-j)*1000:
			ans = str(i) + ' ' + str(j) + ' ' + str(n-i-j)
			break
			
print(ans)
import sys
input = sys.stdin.readline
N, Y = map(int, input().split())
Y //= 1000
for i in range(N):
  x = Y - 10 * i
  for j in range(N - i):
    y = x - 5 * j
    if y < 0: continue
    if i + j + y == N:
      print(i, j, y)
      exit(0) 
print(-1, -1, -1)
def main():
	N,Y = map(int,input().split())
	ListK = [i for i in range(N+1)]
	for a in range(N+1):
		for b in range(N+1-a):
			for c in range(N+1-a-b):
				if 10000*a+5000*b+1000*c == Y:
					print(a,b,c)
					exit()
	print(-1,-1,-1)

if __name__ == '__main__':
	main()
n,y=map(int, input().split())
count = 0
for i in range(n):
  for j in range(n-i):
    k = n - i - j
    if (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())

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

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

for i10000 in range(n):
  for i5000 in range(n):
    i1000 = (y - (i10000*10000 + i5000*5000)) // 1000
    if i1000 >= 0 and i1000 + i5000 + i10000 == n:
      print(i10000, i5000, i1000)
      exit()

print('-1 -1 -1')
n, y = map(int, input().split())
count = 0
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)
            count += 1
if count == 0:
    print(-1,-1,-1)
n,y = map(int,input().split())

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

        

print('-1 -1 -1')
N, Y = list(map(int,input().split()))
def s():
    for i in range(N + 1):
        for j in range(N + 1):
            k = N - i - j
            if k >= 0 and 1000 * i + 5000 * j + 10000 * k  == Y:  print(i, j, k);  return
    print(-1, -1, -1)
s()
n, y = map(int, input().split())
y //= 1000

for a in range(n + 1):
    b = (y - n - 9 * a) // 4
    c = n - a - b
    if 10 * a + 5 * b + c == y and b <= 0 and c <= 0:
        print(a, b, c)
        exit()

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

total = 0

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 and a + b + c == N:
            print(a,b,c)
            sys.exit()
print(-1,-1,-1)
N,Y = map(int,input().split())
x,y,z =-1,-1,-1
if Y<=10000*N and 0<= N <= 2000:
    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)
            x = int(target_x / 9000)
            y = i
            z = N - x - y
            break
print(*[x,y,z])
n, y = map(int, input().split())

for i in range(n):
    for j in range(n):
        if i * 10000 + j * 5000 > y: 
            continue
        num_sen = (y - i * 10000 + j * 5000) // 1000
        if i + j + num_sen == n:
            print(i, j, num_sen)
            exit()
print(-1, -1, -1)
n, y = list(map(int, input().split()))

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

num_10000 = 0
num_5000 = 0
num_1000 = 0

num_10000 = Y // 10000
Y -= num_10000 * 10000
num_5000 = Y // 5000
Y -= num_5000 * 5000
num_1000 = Y // 1000

num = num_10000 + num_5000 + num_1000
for i in range(0, num_10000 + 1):
    for j in range(0, num_5000 + 1):
        res = i * 10 + (num_10000 - i) + j * 5 + (num_5000 - j) + num_1000
        if res == N:
            print(num_10000 - i, num_5000 - j, i * 10 + j * 5 + num_1000)
            exit(0)

print(-1, -1, -1)
if __name__ == "__main__":
    n, y = map(int, input().split())

    # 10000円の数を決め打ちしてつるかめ

    for i in range(n + 1):
        for j in range(n-i):
            tmp = y - i * 10000
            tmp = tmp - j * 5000
            k = n - i - j
            if n == i + j + k and tmp == k * 1000:
                print(str(i) + ' ' + str(j) + ' ' + str(k))
                exit()

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


i5000 = 0
i1000 = 0
for i10000 in range(n):
    for i5000 in range(n - i10000):
        i1000 = n - i10000 - 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())
for x in range(n+1):
    for y in range(n-x+1):
        z = n-(x+y)
        if z >= 0 and 10000*x+5000*y+1000*z == Y:
            print(x,y,z)
            break
    else:
        break
print(-1,-1,-1)
# 085 C
N,Y = map(int, input().split())
x,y,z = -1,-1,-1
for i in range(N):
    for j in range(N):
        if (10000*i + 5000*j + 1000*(N-i-j)) == Y:
            x,y = i,j
            z = N - i - j
            break
    else:
        continue
    break
print(x,y,z)
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
            break
        else:
            pass

if f:
    pass
else:
    print("-1 -1 -1")
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:
            continue
        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')
N,Y=map(int,input().split())
l=0
for i in range (N+1):
    if l==1:
        break
    for j in range(N+1-i):
        if  l==1:
            break
        for k in range(N+1-j-i):
            if l==1:
                break
            elif 10000*i+5000*j+1000*k==Y:
                print(i, j, k)
                l+=1
else :
    print(-1, -1, -1)
N , Y = map(int, input().split())
ans = []
for i in range(N):
    for j in range(N):
        k = N - i - j
        if k >= 0:
            num = i*10000 + j*5000 + (N-i-j)*1000
            if num == Y:
                ans = [i, j, (N-i-j)]

if len(ans) == 0:
    ans = [-1, -1, -1]
    
print(" ".join(map(str,ans)))
import itertools
import sys

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

for i, j, k in itertools.product(x, y, z):
  if 10000 * i + 5000 * j + 1000 * k == Y:
    print(i, j, k)
    sys.exit()
else:
  print('-1 -1 -1')
def main():
    N, Y = map(int,input().split())
    x, y, z = [0, 0, 0]
    
    for i in range(N):
        for j in range(N - i):
            if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y:
                print(i, j , N-i-j)
                return
    
    print(-1, -1, -1)

if __name__ == "__main__":
    main()
N, Y = map(int,input().split())

# N = 1000
# Y = 1234000
search_flag = 0

for count_10k in range(N+1):
    for count_5k in range(N-count_10k):
        count_1k = N - count_10k - count_5k
        if count_10k * 10000 + count_5k * 5000 + count_1k * 1000 == Y:
            print(str(count_10k) + ' ' + str(count_5k) + ' ' + str(count_1k))
            search_flag = 1
            break
    else:
        continue
    break

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

if (Y > N * 10000) or (Y < N * 1000):
    print("{} {} {}".format(-1, -1, -1))

found = False

for x in range(Y//10000+2):
    for y in range(Y//5000+2):
        z = N - x - y
        if z < 0:
            continue
        if (x * 10000 + y * 5000 + z * 1000) == Y:
            print("{} {} {}".format(x, y, z))
            found = True
            break
    if found:
        break
else:
    print("{} {} {}".format(-1, -1, -1))
N, Y = map(int, input().split())
Y = Y//1000
p, q, r = -1, -1, -1
for c in range(Y//10+1):
    R = 5*N+5*c-Y
    if R%4 != 0 or R<0:
        pass
    else:
        p = c
        r = R//4
        q = N-p-r
        break
print(p, q, r)
import sys
n,y=map(int,input().split())
for i in range(n):
    for j in range(n-i):
        cul=10000*i+5000*j
        if cul>y:
            break
        if cul+1000*(n-i-j)==y:
            print(i,j,n-i-j)
            sys.exit()
print(-1,-1,-1)
n,y = map(int,input().split())
ans = '-1 -1 -1'

for i in range(n):
	for j in range(n-i):
		if y == i*10000 + j*5000 + (n-i-j)*1000:
			ans = str(i) + ' ' + str(j) + ' ' + str(n-i-j)
			
print(ans)
N, Y = map(int, input().split())
for x in range(N+1):
  for y in range(N+1-x):
    for z in range(N+1-x-y):
      if x*10000+y*5000+z*1000 == Y:
        print(x,y,z)
        exit(0)
print(-1,-1,-1)
def main():
    n, y = (int(x) for x in input().split())
    y = y//1000
    ans = [-1,-1,-1]

    for i in range(n+1):
        for j in range(n+1):
            k = n - (i + j)
            if k >= 0 and 10*i + 5*j + k == y:
                ans = [i,j,k]
                break
        else:
            break
    print(*ans)

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

a = -1
b = -1
c = -1

for i in range(n+1):
    for j in range(n+1-i):
        money = 10000 * i + 5000 * j + 10000 * (n - i - j)
        if y == money:
            a = i
            b = j
            c = n - i - j

print(str(a)+" ",str(b)+" ",str(c))
n,y=map(int,input().split())

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

maxy = int(Y /5000)
if maxy >= N:
    maxy = N

flag = False

for x in range(N):
    for y in range(maxy):
        if N - x - y < 0:
            break
        else:
            z = N - x -y
        if Y == 10000*x + 5000*y + 1000*z:
            print("{} {} {}".format(x,y,z))
            flag = True
            break
    if flag:
        break

if flag == False:
    print("-1 -1 -1")
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 and z >=0:
      print(z,' ',y,' ',x)
      s = s+1
      break
  else:
    continue
  break
if s == 0:
  print(-1,' ',-1,' ',-1)
N,Y=map(int,input().split())
x = -1
y = -1
z = -1
for i in range(N+1):
    for j in range(N+1):

        k=N-j-i
        sum = i*10000 + j*5000 + k*1000
        if Y==sum and i+j+k==N:
            x=i
            y=j
            z=k
            break

    else:
        continue
    break

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

x, y, z = 0, 0, 0
tmp = Y

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

print(-1, -1, -1)
# https://atcoder.jp/contests/abc085/tasks/abc085_c
n, y = map(int, input().split())
tmp = y // 1000 - n
b = 0
while tmp >= 0:
    tmp -= 4 * b
    if tmp % 9 == 0 and tmp // 9 + b <= n:
        a = tmp // 9
        c = n - (a + b)
        print(a, b, c)
        exit()
    b += 1
print(-1, -1, -1)
n,a=map(int,raw_input().split())
for x in range(n):
    for y in range(n):
        if a==(10000*x)+(5000*y)+((n-(x+y))*1000) and n-(x+y) >= 0:
            print "%d %d %d" % (x,y,n-(x+y))
            quit()
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 = i-j
            n1 = n-i
            break
print(n10, n5, n1)
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 +1000*(N - i - j) == Y:
                print(i,j,N-i-j)
                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-f):

        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())
y //= 1000

cnt = 0

if not(y // 10 <= n <= y):
    print(-1, -1, -1)
else:
    for i in range(y+2):
        for j in range(y//5+2):
            if (y-i-5*j)//10==n-i-j and n-i-j>=0:
                print(n-i-j, j, i)
                break
        else:
            continue
        break
    else:
        print(-1, -1, -1)
N, Y = list(map(int, input().split()))

flag = False
for x in range(N):
  for y in range(N-x):
    z = N - x - y
    if Y == 10000 * x + 5000 * y + 1000 * z:
      print(x, y, z)
      flag = True
      quit()
if ~flag:
  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):
            if 10000*i+5000*j+1000*(n-i-j)==y:
                ans = [i,j,n-i-j]

print(*ans)
N,Y = map(int,input().split())
yukichi = -1
ichiyo = -1
hideyo = -1
count = 0
for x in range(N+1):
  #yukichi = x*10000
  for y in range(N+1):
    #ichiyo = y*5000
    for z in range(N+1):
      #hideyo = z*1000
      total = x*10000 + y*5000 + z*1000
      if x+y+z==N and total == Y:        
        print(x,y,z)
      break
print(-1,-1,-1)
import sys

data = input().split(' ')
number = int(data[0])
price = int(data[1])

for i in range(0, number+1):
  million = 10000 * i
  numberthous = number - i
  for j in range(0, numberthous+1):
    thousand = 1000 * j
    numberhund = numberthous - j
    for k in range(0, numberhund+1):
      hundred = 100 * k
      if(million+thousand+hundred==price):
        print(str(i) + ' ' + str(j) + ' ' + str(k))
        sys.exit()

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

for ykc in range(0,y,10000):
  for ntb in range(0,y-ykc,5000):
    ntm=(y-ykc-ntb)
    nntm=ntm//1000
    nntb=ntb//5000
    nykc=ykc//10000
    if ntm>=0 and ntm%1000==0 and (nntm+nntb+nykc<=n):
      print(nykc, nntb, nntm)
      sys.exit()
print('-1 -1 -1')
N, Y = map(int, input().split())

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