#include<bits/stdc++.h> using namespace std; map<vector<char>, int> mp; static int ls; void dfs(string &s,vector<int> visit, vector<char> u,int cn) { //cout << "start"; if(cn==ls){ mp[u]=1; return; } for (int i = 0; i < ls;i++){ //cout << visit[i]; if(visit[i]==0){ visit[i]=1; u[cn] = s[i]; dfs(s, visit, u,cn+1); visit[i] = 0; } } } bool cmp(const char &a,const char &b){ return a-'A' < b-'A'; } int main() { string s; while(cin >> s){ ls = s.size(); if(ls==1){ cout << s << endl; return 0; } sort(s.begin(), s.end(), cmp); //cout << s << endl; vector<char> u(ls); vector<int> v(ls); dfs(s,v, u,0); for(auto &[res,num]:mp){ for(auto &ans:res){ cout << ans; } cout << endl; } } return 0; }