import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Label:
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            for (int i = 9; i > 0; i--) {
                for (int j = 9; j >= 0; j--) {
                    int cost = i * 10000 + a * 1000 + b * 100 + c * 10 + j;
                    if (cost % n == 0) {
                        System.out.println(i + " " + j + " " + cost / n);
                        continue Label;
                    }
                }
            }
            System.out.println(0);
        }
    }
}