#include #include #define rep(i,n) for(int i=0;i P; template ostream& operator<<(ostream& os, const static_modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const dynamic_modint& a) {os << a.val(); return os;} template istream& operator>>(istream& is, static_modint& a) {long long x; is >> x; a = x; return is;} template istream& operator>>(istream& is, dynamic_modint& a) {long long x; is >> x; a = x; return is;} template istream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const pair& p){os << p.first << ' ' << p.second; return os;} template ostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} template ostream& operator<<(ostream& os, const set& se){for(T x : se) os << x << " "; os << "\n"; return os;} template ostream& operator<<(ostream& os, const unordered_set& se){for(T x : se) os << x << " "; os << "\n"; return os;} template ostream& operator<<(ostream& os, const atcoder::segtree& seg){int n = seg.max_right(0, [](S){return true;}); rep(i, n) os << seg.get(i) << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const atcoder::lazy_segtree& seg){int n = seg.max_right(0, [](S){return true;}); rep(i, n) os << seg.get(i) << (i == n - 1 ? "\n" : " "); return os;} template void chmin(T& a, T b){a = min(a, b);} template void chmax(T& a, T b){a = max(a, b);} const int K = 10; const int INF = 1001001001; using T = tuple; int solve(){ int n; cin >> n; vector dig(K); n = 81181819 - n; rep(i, K){ dig[(K - 1) - i] = n % 10; n /= 10; } vector> dp(K + 1, vector(10, make_tuple(INF, INF, INF))); dp[0][0] = T{0, 0, 0}; vector> memo(100, make_pair(INF, INF)); for(int one = 0; one <= 9; one++){ for(int eight = 0; eight <= 9; eight++){ int sum = one * 1 + eight * 8; if(one + eight < memo[sum].first + memo[sum].second){ memo[sum] = make_pair(one, eight); } } } rep(i, K){ for(int down = 0; down < 10; down++){ int rest = down * 10 + dig[i]; auto [val1, one1, eight1] = dp[i][down]; for(int minus = 0; minus < 100; minus++){ auto [one, eight] = memo[minus]; int val_new = max(val1, one + eight); if(0 <= rest - minus and rest - minus < 10){ auto [val2, one2, eight2] = dp[i + 1][rest - minus]; if(val_new < val2){ dp[i + 1][rest - minus] = T{val_new, one, eight}; } } } } } { vector ans; { auto [val, one, eight] = dp[K][0]; ans.resize(val); } int ten = 1; int down = 0; for(int i = K; i > 0; i--){ auto [val, one, eight] = dp[i][down]; int j = 0; rep(_, one){ ans[j] += 1 * ten; j++; } rep(_, eight){ ans[j] += 8 * ten; j++; } ten *= 10; down = (one * 1 + eight * 8) / 10; // cout << ans; // cout << down << "\n"; // flush(cout); } cout << ans.size() << "\n"; for(auto x : ans){ cout << x << "\n"; assert(x >= 0); } } return 0; } int main(){ int t; cin >> t; rep(_, t) solve(); return 0; }