#include #include #include using namespace std; int main() { char id[51]; while (scanf("%s", id) && id[0] != '#') { if (next_permutation(id, id+strlen(id))) printf("%s\n", id); else printf("No Successor\n"); } return 0; }