#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; #define rep(i,n) for(ll i=0;i=l;i--) using ll = long long; using ld = long double; const ll mod=998244353; #define vout(v) for(auto i :v) cout< #define pb push_back #define vc vector #define vb vector #define uniq(x) sort((x).begin(),(x).end());(x).erase(unique((x).begin(),(x).end()),(x).end()) #define eb emplace_back void no(void) { cout<<"No"< dx={-1,0,1,0,1,1,-1,-1}; vector dy={0,-1,0,1,-1,1,-1,1}; bool isin(ll i,ll j,ll h,ll w) { if(i<0 || i>=h || j<0 || j>=w) return false; return true; } template bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} templateT vecmax(const vector&v){return *max_element(all(v));} templateT vecmin(const vector&v){return *min_element(all(v));} ll safemod(ll num,ll rule) { return (num%rule+rule)%rule; } ll sum(vector &a) { return accumulate(all(a),0ll); } templatevoid vvpr(vector> g) { rep(i,g.size()) { rep(j,g[i].size()) { cout< T modpow(T fl, ll po, ll mode) { // mode: 0=modなし, 1=modあり assert(po>=0); T ret(1); if (mode) { fl%=T(MOD); while (po>0) { if (po&1) ret=(ret*fl)%T(MOD); fl=(fl*fl)%T(MOD); po>>=1; } } else { while (po>0) { if(po&1) ret*=fl; fl*=fl; po>>=1; } } return ret; } int main() { ll t; cin>>t; vl f={0,1,2,3,4,5,6,7,8,9,1,1,2,3,4,5,6,7,8,9,2,2,2,3}; vl ansl={-1,1,2,1,4,2,1,3,8,2,1,5,3,6,2,1,9,8,3,8,2,1,4,18,7,3,5,2,1,10,4,6,6,3,6,2,1,5,9,4,4,4,3,3,2,1,1,1,2,1,4,2,1,3,8,2,1,5,3,6,2,1,12,8,3,8,2,1,4,8,7,3}; vl ansr={-1,1,2,2,4,3,3,4,8,4,4,6,5,7,5,5,13,9,6,11,6,6,7,22,9,7,8,7,7,17,8,10,11,8,12,8,8,11,17,9,10,11,9,10,9,9,10,11,12,12,14,13,13,14,18,14,14,16,15,17,15,15,25,19,16,20,16,16,17,22,19,17}; while(t--) { ll n; cin>>n; if(n>=72) { ll B=888888888888888880ll; ll p=n/9,q=n%9; ll lef=B+q; ll dif=(n-8*(9-q))/9; ll rig=B+8+dif; cout<