#include using namespace std; #define myassert(f) (f?(void)0:((cout<<"cannot get result length"<> tmp(57,make_pair(1e9,1e9)); tmp[0] = make_pair(0,0); #define f(i) (tmp[i].first+tmp[i].second) for (int i(0);i < 57;++i){ if (i+8<57&&f(i+8)>f(i)+1) tmp[i+8] = tmp[i],++tmp[i+8].first; if (i+1<57&&f(i+1)>f(i)+1) tmp[i+1] = tmp[i],++tmp[i+1].second; } int q; cin >> q; while(q--){ int n; cin >> n; string m = to_string(81181819-n); int s = m.size(); vector dp(s+1,vector>(10,make_tuple(1e9,1e9,1e9))); dp[0][0] = make_tuple(0,-1,-1); for (int i(0);i < s;++i) for (int k(0);k < 10;++k) if (get<0>(dp[i][k])!=1e9){ auto [a,b,c] = dp[i][k]; int j = m[s-i-1]-'0'-k; if (j<0) j += 10; for (;j < 57;j+=10) if (get<0>(dp[i+1][(j+k)/10])>max(a,f(j))) dp[i+1][(j+k)/10] = make_tuple(max(a,f(j)),i,k); } auto [r,a,b] = dp[s][0]; int c = 0; myassert(r!=1e9); vector R(r,vector(s)); for (int i(0);i < s;++i){ int k = 0; c = c*10+(m[s-i-1]-'0'