#include using namespace std; // #include // using namespace atcoder; // using mint = modint998244353; using ll = long long; #define fix(x) fixed << setprecision(x) #define rep(i, n) for(int i = 0; i < n; ++i) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> mp; vector v(5559); for(int i=1;i<=5558;++i){ int x = 0, m = i, l = 1; while(m){ x += (m%3 + (m%3)/2*6)*l; m /= 3; l *= 10; } v[i] = x; mp[x] = {x}; for(int j=1;j<=i;++j) mp[v[j]+x] = {v[j], x}; } int t; cin >> t; while(t--){ int n; cin >> n; n = 81181819 - n; vector ans; if(mp.count(n)) ans = mp[n]; else{ if(n<=7){ ans.assign(n,1); }else if(n==15){ ans.assign(5,1); ans[0] = 11; }else{ for(auto& [p,q]:mp){ if(mp.count(n-p)){ auto& r = mp[n-p]; if(ans.empty() || ans.size()>q.size()+r.size()){ ans.resize(0); for(int x:q) ans.emplace_back(x); for(int x:r) ans.emplace_back(x); } } } } } assert(!ans.empty()); cout << ans.size() << '\n'; for(int x:ans) cout << x << '\n'; } return 0; }