import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;
class Main{
static int MAX_SIZE = 10 ;
static int G[][] = new int [MAX_SIZE][MAX_SIZE];
static boolean visit[] = new boolean[MAX_SIZE] ;
static int n;
static Vector<Integer> v ;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
Arrays.fill(G[i], 1);
}
v = new Vector<Integer>();
while (in.hasNext()){
String st = in.nextLine();
n = st.length();
for (int i = 0; i < n; i++) {
Arrays.fill(visit, false);
v.clear();
DFS(st,i);
}
}
}
//从定点n开始深搜
public static void DFS(String st, int v){
Main.v.add(v);
if (Main.v.size() == n){
for (int i = 0; i < n; i++) {
System.out.print(st.charAt(Main.v.get(i)));
}
System.out.println();
}
visit[v] = true;
for (int w = nextAdj(v);w>=0; w = nextAdjofw(w,v)){
if (!visit[w])
DFS(st,w);
visit[w] = false;
Main.v.removeElement(w);
}
}
/**
* @param w
* @param n
* @return
*/
private static int nextAdjofw(int w, int v) {
// TODO Auto-generated method stub
for (int i = w+1; i < n; i++) {
if (G[v][i]==1&&i!=v&&!visit[i])
return i;
}
return -1;
}
/**
* @param n
* @return
*/
private static int nextAdj(int v) {
// TODO Auto-generated method stub
for (int i = 0; i < n; i++) {
if (G[v][i]==1&&i!=v&&!visit[i])
return i;
}
return -1;
}
}
import java.util.Scanner;
import java.util.Vector;
class Main{
static int MAX_SIZE = 10 ;
static int G[][] = new int [MAX_SIZE][MAX_SIZE];
static boolean visit[] = new boolean[MAX_SIZE] ;
static int n;
static Vector<Integer> v ;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
Arrays.fill(G[i], 1);
}
v = new Vector<Integer>();
while (in.hasNext()){
String st = in.nextLine();
n = st.length();
for (int i = 0; i < n; i++) {
Arrays.fill(visit, false);
v.clear();
DFS(st,i);
}
}
}
//从定点n开始深搜
public static void DFS(String st, int v){
Main.v.add(v);
if (Main.v.size() == n){
for (int i = 0; i < n; i++) {
System.out.print(st.charAt(Main.v.get(i)));
}
System.out.println();
}
visit[v] = true;
for (int w = nextAdj(v);w>=0; w = nextAdjofw(w,v)){
if (!visit[w])
DFS(st,w);
visit[w] = false;
Main.v.removeElement(w);
}
}
/**
* @param w
* @param n
* @return
*/
private static int nextAdjofw(int w, int v) {
// TODO Auto-generated method stub
for (int i = w+1; i < n; i++) {
if (G[v][i]==1&&i!=v&&!visit[i])
return i;
}
return -1;
}
/**
* @param n
* @return
*/
private static int nextAdj(int v) {
// TODO Auto-generated method stub
for (int i = 0; i < n; i++) {
if (G[v][i]==1&&i!=v&&!visit[i])
return i;
}
return -1;
}
}