#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
using namespace std;
int main( ) {
int n;
while ( cin >> n )
{
cout << n << " => " ;
stringstream ss;
ss << n;
string s;
ss >> s;
if ( next_permutation( s.begin ( ) , s.end ( ) ) )
cout << s << endl;
else
cout << "Не вийшло" << endl;
}
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCBuOwoJd2hpbGUoIGNpbiA+PiBuICkKCXsKCQljb3V0IDw8IG4gPDwgIiA9PiAiOwoJCXN0cmluZ3N0cmVhbSBzczsKCQlzcyA8PCBuOwoJCXN0cmluZyBzOwoJCXNzID4+IHM7CgkJaWYoIG5leHRfcGVybXV0YXRpb24oIHMuYmVnaW4oKSwgcy5lbmQoKSApICkKCQkJY291dCA8PCBzIDw8IGVuZGw7CgkJZWxzZQoJCQljb3V0IDw8ICLQndC1INCy0LjQudGI0LvQviIgPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9