Quasi-binary number (qbin)

Description


We call the number consisting of 0 and 1 in the decimal number "quasi-binary number", input a positive integer (n), and decompose it into the smallest sum of "quasi-binary numbers".

Format


Input

The first line is a positive integer (t(≤10)), which represents the number of data groups; the next line is a positive integer (n(≤10^9)).

Output

For each (n), sort the decomposed quasi-binary numbers from smallest to largest and output them. If there are multiple sets of solutions, output the solution with the smallest lexicographic order.

Sample


Input

2
9
463

Output

1 1 1 1 1 1 1 1 1
10 10 110 111 111 111

Sample Explanation

When (n)=463, it can be decomposed into ( ext{11 11 110 110 110 111}), but the smallest lexicographical solution is ( ext{10 10 110 111 111 111}).

Sample Code


#include <cstdio>
int main(){
	freopen("qbin.in", "r", stdin);
	freopen("qbin.out", "w", stdout);
	int d[10]={0, 1};
	for (int i=2; i<10; i++)
		d[i]=d[i-1]*10;
	int t, n;
	scanf("%d", &t);
	while (t--){
		scanf("%d", &n);
		int w, a[10]={0};
		for (w=0; n; n/=10)
			a[++w]=n%10;
		int k=0;
		int c[10]={0};
		for (int i=1; i<=w; i++){
			if (k<a[i]) k=a[i];
			for (int j=1; j<=a[i]; j++)
				c[j]+=d[i];
		}
		for (int i=k; i>0; i--)
			printf("%d ", c[i]);
		printf("
");
	}
	return 0;
} 
原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13806425.html