#include<bits/stdc++.h>
using namespace std;

vector<string> v;

void permutation(string &temp,int i){
    if(i == temp.length()){
        v.push_back(temp);
    }

    for(int j=i;j<temp.length();j++){
        swap(temp[i],temp[j]);
        permutation(temp,i+1);
        swap(temp[i],temp[j]);
    }
    return;
}

int main() {
    string s;
    cin >> s;
    string temp = s;
    int l = s.length();

    permutation(temp,0);
    sort(v.begin(),v.end());
    for(auto &i : v){
        if(i == s)
            break;

        cout << i << endl;
    }

    return 0;
}