#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; template istream& operator >> (istream& is, vector& vec){for(T& val: vec) is >> val; return is;} template istream& operator , (istream& is, T& val){ return is >> val;} template ostream& operator << (ostream& os, const vector& vec){for(int i=0; i ostream& operator , (ostream& os, const T& val){ return os << " " << val;} template ostream& operator >> (ostream& os, const T& val){ return os << " " << val;} long long cnt_kado_num(long long x){ string s; char buff[100]; sprintf(buff,"%lld", x); s = buff; vector>> dp(11, vector>(11, vector(2, 0))); dp[10][10][0] = 1; for(int i=0; i>> dp_(11, vector>(11, vector(2, 0))); for(int c=1; c<10; c++){ if(i==0) dp_[10][c][ck) continue; int t_ = t || ck) break; for(int a=0; ak) break; for(int a=b+1; a<10; a++){ if(a==c) continue; int t_ = t || c> t; assert(1<=t); assert(t<=10); long long d = cnt_kado_num(99); while(t--){ long long k; cin >> k; assert(1<=k); assert(k<=10000000000LL); k += d; long long lb = 0; long long ub = 1LL<<58; while(ub-lb>1){ long long mid = (lb+ub)/2; (cnt_kado_num(mid)>=k ? ub : lb) = mid; } cout << ub << endl; } assert(!(cin>>t)); return 0; }