#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,a) for(int i=(int)0;i<(int)a;++i) #define pb push_back #define eb emplace_back using ll=long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 50; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; void solve(){ string x; cin>>x; sort(x.rbegin(),x.rend()); int n=x.size(); mapmp; rep(i,n){ mp[x[i]]++; } if(mp.size()==1){ cout<<-1<<"\n"; return; } if(mp.size()==2&&x[1]=='0'){ cout<<-1<<"\n"; return; } for(int i=n-2;i>=0;--i){ if(x[i]!='0'){ swap(x[i],x.back()); break; } } rep(i,n)cout<