// Arup Guha
// 2/9/2013
// Solution to 2010 MCPC Problem I: Egyptian Fractions

import java.util.*;

public class i {

	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		long num = stdin.nextLong();
		long den = stdin.nextLong();

		// Process each case.
		while (num != 0) {

			// Store denominators here.
			ArrayList<Long> list = new ArrayList<Long>();
			long tryval = 2;

			while (true) {

				// Try to use this value.
				if (tryval*num >= den) {

					// Subtract this term out.
					long newnum = tryval*num - den;
					long newden = den*tryval;
					long mygcd = gcd(newnum, newden);
					newnum = newnum/mygcd;
					newden = newden/mygcd;

					// Creates a valid fraction, so add it in.
					if (newden < 1000000) {
						list.add(tryval);
						num = newnum;
						den = newden;
					}
					
					// Denominator is too big, so skip.
					else
						tryval++;

					// We've subtracted everything out, so quit!
					if (num == 0) break;
				}
				
				// Try the next denominator.
				else
					tryval++;

				// We can stop here.
				if (tryval == 1000000) break;
			}

			// Output list of denominators.
			for (int i=0; i<list.size(); i++)
				System.out.print(list.get(i) + " ");
			System.out.println();

			// Get next case.
			num = stdin.nextLong();
			den = stdin.nextLong();
		}
	}

	public static long gcd(long a, long b) {
		if (a == 0) return b;
		if (b == 0) return a;
		return gcd(b, a%b);
	}
}