#include<bits/stdc++.h>
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
#define putcase cout<<"Case "<<++cse<<":"
using namespace std;
int main()
{
string s;
while(cin>>s){
int cnt=0;
if(s=="#")
return 0;
while(next_permutation(s.begin(),s.end())){
// string t = ;
// cout<<s<<endl;
cnt++;
if(cnt!=0){
cout<<s<<endl;
break;
}
}
if(cnt==0)
cout<<"No Successor\n";
}
return 0;
}
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
#define putcase cout<<"Case "<<++cse<<":"
using namespace std;
int main()
{
string s;
while(cin>>s){
int cnt=0;
if(s=="#")
return 0;
while(next_permutation(s.begin(),s.end())){
// string t = ;
// cout<<s<<endl;
cnt++;
if(cnt!=0){
cout<<s<<endl;
break;
}
}
if(cnt==0)
cout<<"No Successor\n";
}
return 0;
}
No comments:
Post a Comment