import java.util.ArrayList;
import java.util.Collections;
public class Solution {
ArrayList<String> list = new ArrayList<String>();
public ArrayList<String> Permutation(String str) {
char a[]=str.toCharArray();
f(a,0);
Collections.sort(list);
return list;
}
public void f(char a[],int k){
if(k==a.length-1)
list.add(new String(a));
for(int i=k;i<a.length;i++){
while(i!=k&&i<a.length&&a[k]==a[i])
i++;
if(i==a.length)
break;
char temp=a[k];
a[k]=a[i];
a[i]=temp;
f(a,k+1);
temp=a[k];
a[k]=a[i];
a[i]=temp;
}
}
}