use-bit
Source: hackerearth
Difficulty: EASY

The problem statement is simple. You are given a string and you are 
supposed to print all the distinct permutations of the string, as they would appear in an dictionary. 

INPUT
The first and only line of the input contains a single string, S.

OUTPUT
The output contains the required strings, each string in a seperate line.

CONSTRAINTS
1 ≤ |S| ≤ 9

SAMPLE INPUT
abc

SAMPLE OUTPUT
abc
acb
bac
bca
cab
cba


from itertools import permutations
perms = [''.join(p) for p in permutations(input())]
perms = list(set(perms))
perms.sort()
for i in range(len(perms)):
	print(perms[i])


from itertools import permutations
s = list(input())
k = list(set(permutations(s)))
k.sort()
for p in k:
	print(''.join(p))