#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a void drop(const T &x){cout<>s; sort(s.rbegin(),s.rend()); if(!prev_permutation(s.begin(),s.end())) drop(-1); if(s[0]=='0') drop(-1); cout<