uva146 ID码
/*极水的题。。。*/
#include"iostream"
#include"stdio.h"
#include"stdlib.h"
#include"algorithm"
#include"string.h"
using namespace std;
char s[1005];
int main()
{
while(scanf("%s",s),s[0]!='#')
{
if(next_permutation(s,s+strlen(s)))
cout<<s<<endl;
else cout<<"No Successor"<<endl;
}
return 0;
}