// Arup Guha
// 6/29/2013
// Solution to 2012 Mid-Central Regional Contest Problem B: Digit Solitaire

import java.util.*;

public class b {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();

		// Go through all cases.
		while (n != 0) {

			// Print out the next number in the sequence.
			while (n >= 10) {
				System.out.print(n+" ");
				n = prodDigits(n);
			}
			
			// Print the last line and go to the next case.
			System.out.println(n);
			n = stdin.nextInt();
		}
	}

	// Returns the product of the digits in n.
	public static int prodDigits(int n) {

		if (n%10 == 0) return 0;
		int prod = 1;
		while (n > 0) {
			prod = prod*(n%10);
			n = n/10;
		}
		return prod;
	}
}