T = int(input())
for tc in range(1, T+1):
N = int(input())
lst = []
money = [50000, 10000, 5000, 1000, 500, 100, 50, 10]
for i in money:
if N >= i:
lst.append(N // i)
N = N - N // i * i
else:
lst.append(0)
print('#{} '.format(tc), end='')
for i in lst:
print(i, end=' ')
print()