import java.io.FileReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Main {
	static class stamp_set{
		ArrayList<Integer> stamp_values;
		int values[];
		
		stamp_set(stamp_set other, int n) {
			this(other.stamp_values, n);
		}
		stamp_set(ArrayList<Integer> other, int n) {
			stamp_values = new ArrayList<Integer>(other);
			stamp_values.add(n);
		}
		
		void calc() {
			values = new int[200];
			for (int i = 1; i < 200; i++)
				values[i] = 10;
			values[0] = 0;
			int max = 0;
			for (int i = 1; i <= 9 - stamp_values.size(); i++) {
				for (int v : stamp_values)
					for (int j = 0; j <= max; j++)
						values[j + v] = Math.min(values[j] + 1, values[j + v]);
				max += stamp_values.get(stamp_values.size() - 1);
			}
		}
		int max_stamp() { return stamp_values.get(stamp_values.size() - 1); }
		int max_val(int t) {
			int i = 0;
			while (values[i + 1] <= t) i++;
			return i;
		}
		void print(int t) {
			for (int v : stamp_values)
				System.out.printf("%3d", v);
			System.out.printf(" ->%3d\n", max_val(t));
		}
	}
	
	static stamp_set[][] opt;
	
	static {
		ArrayList<ArrayList<stamp_set>> data = new ArrayList<ArrayList<stamp_set>>();
		for (int i = 1; i < 10; i++) {
			data.add(new ArrayList<stamp_set>());
		}
		stamp_set one = new stamp_set(new ArrayList<Integer>(), 1);
		one.calc();
		data.get(1).add(one);
		for (int i = 2; i <= 8; i++) {
			Iterator<stamp_set> prev_sets = data.get(i - 1).iterator();
			while (prev_sets.hasNext()) {
				stamp_set prev = prev_sets.next();
				for (int j = prev.max_stamp() + 1; j <= prev.max_val(9 - i) + 1; j++) {
					stamp_set next = new stamp_set(prev, j);
					next.calc();
					data.get(i).add(next);
				}				
			}
		}
		
		opt = new stamp_set[10][10];
		for (int i = 1; i < 9; i++) {
			for (int j = 1; i + j <= 9; j++) {
				opt[i][j] = one;
				for (stamp_set ss : data.get(i))
					if (ss.max_val(j) >= opt[i][j].max_val(j)) opt[i][j] = ss;				
			}
		}		
	}
	
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			int t = in.nextInt(), n = in.nextInt();
			if (n == 0) break;
			opt[n][t].print(t);
		}
	}
}
