#include //#include using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); // 高々7個あればできる const int iwai = 81181819; vector list(8, vector(63, vector())); auto dfs = [&](auto &&self, vector &x)->void { if (x.size() >= 8)return; { int sum = 0; int sz = x.size(); for (auto e : x)sum += e; if (list[sz][sum].empty()) { // // cout << sz << " " << sum << endl; list[sz][sum] = x; } } vectorv = { 0,1,8 }; rep(i, 3) { x.push_back(v[i]); self(self, x); x.pop_back(); } }; vectoremp = {}; dfs(dfs, emp); map>mp; rep(i, 8)mp[{0, i}] = { true,0 }; int cnt = 00; auto calc = [&](auto &&self, int x, int size)->pair { if (mp.count({ x,size }))return mp[{x, size}]; mp[{x, size}] = make_pair(false, -1); for (int i = x % 10; i < 63; i += 10) if (!list[size][i].empty()) { int nx = x - i; if (nx < 0)continue; nx /= 10; //cout << x << "->" << nx << endl; auto tmp = self(self, nx, size); if (tmp.first)mp[{x, size}] = make_pair(true, i); } return mp[{x, size}]; }; int t; cin >> t; while (t--) { int n; cin >> n; int x = iwai - n; vectorans; auto solve = [&](int x, int size)->void { vector>anssub; ans.resize(size); anssub.resize(size); while (x) { auto[can, tar] = mp[{x, size}]; rep(i, size) { anssub[i].push_back(list[size][tar][i]); } x = (x - tar) / 10; } rep(i, size) { reverse(all(anssub[i])); for (auto e : anssub[i]) { ans[i] = ans[i] * 10 + e; } } }; rep2(i, 1, 8) { auto res = calc(calc, x, i); if (res.first) { // cout << "can" << i << endl; solve(x, i); break; } } cout << ans.size() << endl; for (auto e : ans)cout << e << " "; cout << endl; } return 0; }