#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll=long long; template using V = vector; template using P = pair; using vll = V; using vvll = V; #define rep(i, k, n) for (ll i=k; i<(ll)n; ++i) #define REP(i, n) rep(i, 0, n) #define ALL(v) v.begin(),v.end() template inline bool chmax(T& a, T b) {if (a inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;} #define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<> s; map sc; REP(i, s.size()) sc[s[i]]++; if (sc['0'] == s.size() - 1) cout << -1 << '\n'; else if (sc.size() == 1) cout << -1 << '\n'; else { V< P > ssc; for (P _sc: sc) ssc.emplace_back(_sc); for (ll i = ssc.size() - 1; i > 1; i--) { for (ll j = 0; j < ssc[i].second; j++) cout << ssc[i].first; } for (ll i = 0; i < ssc[1].second - 1; i++) cout << ssc[1].first; for (ll i = 0; i < ssc[0].second; i++) cout << ssc[0].first; cout << ssc[1].first << '\n'; } return 0; }