import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());

        // 紙幣は0枚～N枚数まで使用できるので、Nに1加算する
        String ans = countMoney(N, Y);
        System.out.println(ans);
    }

    private static String countMoney(int N, int Y) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            }
        }
        return "-1 -1 -1";
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());

        // 紙幣は0枚～N枚数まで使用できるので、Nに1加算する
        String ans = countMoney(N, Y);
        System.out.println(ans);
    }

    private static String countMoney(int N, int Y) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            }
        }
        return "-1 -1 -1";
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());

        // 紙幣は0枚～N枚数まで使用できるので、Nに1加算する
        String ans = countMoney(N, Y);
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());

        // 紙幣は0枚～N枚数まで使用できるので、Nに1加算する
        String ans = countMoney(N, Y);
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int Y = Integer.parseInt(sc.next()); Y Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc String ans = countMoney(N, Y); ans countMoney(N, Y) countMoney N Y System.out.println(ans) System.out.println System.out System System.out ans String[] args args private static String countMoney(int N, int Y) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            }
        }
        return "-1 -1 -1";
    } countMoney {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            }
        }
        return "-1 -1 -1";
    } StringBuilder sb = new StringBuilder(); sb new StringBuilder() for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            }
        } int i = 0; int i = 0; i 0 i < N + 1 i N + 1 N 1 i++ i++ i {
            for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            }
        } {
            for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            }
        } for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            } int j = 0; int j = 0; j 0 j < N + 1 j N + 1 N 1 j++ j++ j {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            } {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            } int remain = Y - (i * 10000 + j * 5000); remain Y - (i * 10000 + j * 5000) Y (i * 10000 + j * 5000) i * 10000 i 10000 j * 5000 j 5000 int use = i + j + remain / 1000; use i + j + remain / 1000 i + j + remain / 1000 i j remain / 1000 remain 1000 if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                } use == N && remain / 1000 >= 0 use == N use N remain / 1000 >= 0 remain / 1000 remain 1000 0 {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                } sb.append(i + " ") sb.append sb i + " " i " " sb.append(j + " ") sb.append sb j + " " j " " sb.append(String.valueOf(remain / 1000)) sb.append sb String.valueOf(remain / 1000) String.valueOf String remain / 1000 remain 1000 return sb.toString(); sb.toString() sb.toString sb return "-1 -1 -1"; "-1 -1 -1" int N N int Y Y public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());

        // 紙幣は0枚～N枚数まで使用できるので、Nに1加算する
        String ans = countMoney(N, Y);
        System.out.println(ans);
    }

    private static String countMoney(int N, int Y) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            }
        }
        return "-1 -1 -1";
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());

        // 紙幣は0枚～N枚数まで使用できるので、Nに1加算する
        String ans = countMoney(N, Y);
        System.out.println(ans);
    }

    private static String countMoney(int N, int Y) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            }
        }
        return "-1 -1 -1";
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());

        // 紙幣は0枚～N枚数まで使用できるので、Nに1加算する
        String ans = countMoney(N, Y);
        System.out.println(ans);
    }

    private static String countMoney(int N, int Y) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < N + 1; j++) {
                int remain = Y - (i * 10000 + j * 5000);
                int use = i + j + remain / 1000;
                if (use == N && remain / 1000 >= 0) {
                    sb.append(i + " ");
                    sb.append(j + " ");
                    sb.append(String.valueOf(remain / 1000));
                    return sb.toString();
                }
            }
        }
        return "-1 -1 -1";
    }
}
