#include <algorithm>
#include<iostream>
#include <string.h>
#include<stdio.h>
using namespace std;
int main (){
char b[7] ;
int n;
while (scanf("%s",b)!=EOF){
n = strlen(b);
do{
printf("%s\n",b);
}while (next_permutation(b,b+n));
printf("\n");
}
return 0;
}