#include using namespace std; using ll=long long; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int ttt; cin>>ttt; auto f=[](ll x)->ll{ if(x==0)return 0; string s=to_string(x); int n=s.size(); vector dp(20); dp[0]=1; for(int i=0;i ndp(20); for(int j=0;j<20;j++){ int x=j/10,y=j%10; for(int d=0;d<10;d++){ if(d> v(101,make_pair(-1,-1)); for(int i=1;i<=100;i++){ for(int j=1;j<=10000;j++){ int sum=0; for(int k=j;k<=j+i;k++){ int d=0; int x=k; while(x>0){ d=max(d,x%10); x/=10; } sum+=d; if(sum==i){ v[i]=make_pair(j,k); break; } if(sum>i)break; } if(v[i].first!=-1)break; } } while(ttt--){ ll n; cin>>n; if(n<=100){ cout<