#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n = 81181819; int T; cin >> T; while(T--){ int N; cin >> N; N = n-N; int best = 1000; pair,vector> memo; vector One(10),Eight(10); bool ok = false; auto dfs = [&](auto dfs,int left,int now=0,int d=0) -> void { if(best <= now) return; if(left < 0) return; if(left == 0){ best = now,memo = {One,Eight}; return; } for(int one=0; one<=7; one++) for(int eight=0; one+eight<=7; eight++){ int v = one+eight*8; One.at(d) = one,Eight.at(d) = eight; if((left-v)%10 == 0) dfs(dfs,(left-v)/10,max(now,one+eight),d+1); } }; dfs(dfs,N); tie(One,Eight) = memo; vector answer; while(true){ long long now = 0; for(int i=8; i>=0; i--){ now *= 10; if(One.at(i)) One.at(i)--,now++; else if(Eight.at(i)) Eight.at(i)--,now+=8; } if(now == 0) break; answer.push_back(now); } cout << answer.size() << "\n"; for(auto a : answer) cout << a << "\n"; } }