The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
import sys

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

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

if 10000 * N < Y and 1000 * N > Y :
  print(str(x) + " " + str(y) + " " + str(z))
  sys.exit(1)


diff = 10000 * N - Y

#print("diff : " + str(diff))

for i in range(diff//9000+1) :
  diff_ = diff - 9000 * i
  #print("diff_ : " + str(diff_))

  if diff_ % 5000 == 0 :
    z = i
    y = diff_ // 5000
    x = N - y - z
    #print(str(x) + " " + str(y) + " " + str(z))

    if (x > -1) :
      print(str(x) + " " + str(y) + " " + str(z))
      sys.exit(0)

print(str(x) + " " + str(y) + " " + str(z))
import sys
#import numpy as np

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

ans_x, ans_y, ans_z = -1, -1, -1

#n_list = np.append([0], range(N+1))
#n_list = np.append(n_list, [N])

#print(n_list)
#print(len(n_list))
#print(range(len(n_list)))
#print(range(10 ,len(n_list)))

for i in range(N+1) :
  x = i
  
  
  #  continue

  for j in range(N+1-x) :
    y = j
    z = N - x - y
    sum = 10000*x + 5000*y + 1000*z
    
    if sum == Y :
      ans_x=x
      ans_y=y
      ans_z=z

print(str(ans_x) + " " + str(ans_y) + " " + str(ans_z))