#include #define rep(i,n) for(int i=0;i> x; map mp; rep(i,x.size()){ mp[x[i]] ++; } if(mp.size() == 1){ cout << -1 << endl; return 0; } if(mp.size() == 2 && mp['0'] == x.size() -1){ cout << -1 << endl; return 0; } bool fi = true,se = false ; char s; for(auto p:mp){ if(fi){ fi = false;se = true;} else if(se){s = p.first;break;} } mp[s] --; string ans = ""; ans += s ; for(auto p:mp){ rep(i,p.second){ ans += p.first ; } } reverse(ans.begin(),ans.end()); cout << ans << endl; return 0; }