import sys from functools import lru_cache from collections import deque LIST=[[] for i in range(8)] LIST[0]=[(0,[])] Q=[0,1,8] for i in range(8): SET=set() for now,L in LIST[i-1]: for q in Q: if now+q in SET: continue SET.add(now+q) LIST[i].append((now+q,L+[q])) MAX=81181819 T=int(input()) for tests in range(T): x=int(input()) a=MAX-x ANS=[] flag=0 for i in range(8): #print("!",i) Q=[(a,[0 for i in range(i)],0)] Q=deque(Q) while Q: #print(Q) x,ANS,now=Q.popleft() if x==0: flag=1 LANS=ANS[:] break for s,L in LIST[i]: if x%10==s%10 and x>=s: nex=x-s ANS2=ANS[:] for j in range(i): ANS2[j]+=L[j]*(10**now) Q.append((nex//10,ANS2,now+1)) if flag: break print(len(LANS)) for ans in LANS: print(ans)