using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int n = int.Parse(strs[0]);
            int yen = int.Parse(strs[1]);

            int x = 0;
            int y = 0;
            int z = 0;

            bool flag = false;
            bool onemoreFlag = false;

            int sen = (yen / 1000) % 10;
            int gosen = 0;

            if (sen >= 5)
            {
                onemoreFlag = true;
            }

            n -= sen;
            yen -= sen * 1000;

            if (Check(yen, n, ref x, ref y, ref z))
            {
                flag = true;
            }

            if (!flag && onemoreFlag)
            {
                sen -= 5;
                gosen += 1;
                n += 4;

                if (Check(yen, n, ref x, ref y, ref z))
                {
                    flag = true;
                }
            }

            if (flag)
            {
                y += gosen;
                z += sen;
            }
            else
            {
                x = -1;
                y = -1;
                z = -1;
            }

            Console.WriteLine("{0} {1} {2}", x, y, z);
        }

        static bool Check_5000_1000(int yen, int n, ref int y, ref int z)
        {
            // 5000円札を最も多くした場合
            int gosen = yen / 5000;
            int sen = yen - gosen * 5000;

            if (n > yen / 1000)
            {
                return false;
            }
            else if (n < gosen + sen)
            {
                return false;
            }
            else if (gosen + sen == n)
            {
                y = gosen;
                z = sen;
                return true;
            }

            int diff = n - (gosen + sen);

            if (diff % 4 != 0)
            {
                return false;
            }

            int x = diff / 4;
            gosen -= x;

            if (gosen < 0)
            {
                return false;
            }

            sen += x * 5;

            y = gosen;
            z = sen;

            return true;
        }

        static bool Check(int yen, int n, ref int x, ref int y, ref int z)
        {
            int man = yen / 10000;

            if (n < man)
            {
                return false;
            }
            else if (man == n)
            {
                x = man;
                y = 0;
                z = 0;

                return true;
            }

            int nokori = n - man;

            int sen = yen / 1000;
            if (n > sen)
            {
                return false;
            }
            else if (sen == n)
            {
                x = 0;
                y = 0;
                z = sen;

                return true;
            }

            for (int i = 0; i < n; ++i)
            {
                if (Check_5000_1000(yen - i * 10000, n - i, ref y, ref z))
                {
                    x = i;
                    return true;
                }
            }

            return false;
        }
    }
}


Measured memory_bytes: 13140