// Arup Guha
// 3/31/2016
// Solution to 2004 MCPC Problem A: Primary X-Subfactor Series

import java.util.*;

public class a {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		String n = stdin.next();

		// Process each case.
		while (!n.equals("0")) {

			// Get result and solve.
			ArrayList<String> res = solve(n);
			for (int i=0; i<res.size()-1; i++)
				System.out.print(res.get(i)+" ");
			System.out.println(res.get(res.size()-1));

			// Get next case.
			n = stdin.next();
		}
	}

	public static ArrayList<String> solve(String n) {

		// Initial answer is doing nothing.
		ArrayList<String> best = new ArrayList<String>();

		int len = n.length();

		// Try taking out each substring.
		for (int i=0; i<(1<<len); i++) {

			// Get split and screen out bad ones.
			String[] split = getSplit(n, i);
			if (!valid(n, split[0])) continue;

			// Recursively solve on rest.
			ArrayList<String> tmp = solve(split[1]);

			// Update if necessary.
			if (beats(tmp, best, 0))
				best = tmp;
		}

		// This one always goes first, so put it there.
		best.add(0, n);
		return best;
	}

	public static String[] getSplit(String n, int mask) {

		String[] res = new String[2];
		res[0] = "";
		res[1] = "";

		// Each item gets added to one string or the other...
		for (int i=0; i<n.length(); i++) {
			if ((mask & (1<<i)) > 0)
				res[0] = res[0] + n.charAt(i);
			else
				res[1] = res[1] + n.charAt(i);
		}

		// Trim split[1].
		while (res[1].length() > 1 && res[1].charAt(0) == '0')
			res[1] = res[1].substring(1);

		// We're done return both strings.
		return res;
	}

	public static boolean valid(String n, String split) {

		// split must have no leading 0s and not be 1.
		if (split.length() == 0 || split.length() == n.length()) return false;
		if (split.charAt(0) == '0') return false;
		if (split.equals("1")) return false;

		// Okay, get these two numbers and do the mod...
		int div = Integer.parseInt(split);
		int num = Integer.parseInt(n);
		return num%div == 0;
	}

	public static boolean beats(ArrayList<String> list1, ArrayList<String> list2, int k) {

		// Easy cases.
		if (list1.size() > list2.size()) return true;
		if (list1.size() < list2.size()) return false;
		if (k == list1.size()) return false;

		// Now we look to break the tie by values.
		int val1 = Integer.parseInt(list1.get(k));
		int val2 = Integer.parseInt(list2.get(k));
		if (val1 < val2) return true;
		if (val1 > val2) return false;

		// Move onto the next value.
		return beats(list1, list2, k+1);
	}
}