1. 
/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 156 - Ananagrams
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=98&problem=92&mosmsg=Submission+received+with+ID+8015348
*
* @author Evgeni Pavlidis
* @version 1.0, 06/03/2010
*
* Method : Ad hoc
* Status : Accepted
* Runtime: 0.116
*/

import java.io.*;
import java.util.*;

class Main {
public static void main(String...args)
{
Scanner sc = new Scanner(System.in);

List<String> domain = new LinkedList<String>();
List<Character> list = new ArrayList<Character>();
Set<List<Character>> set = new HashSet<List<Character>>();
Set<List<Character>> anagrams = new HashSet<List<Character>>();
Set<String> result = new TreeSet<String>();

String input, word;

// read input
while(!(input = sc.next()).equals("#"))
domain.add(input);

// find anagrams
for(String s: domain)
{
word = s.toLowerCase();

list.clear();
for(int i = 0; i < word.length(); i++)
list.add(word.charAt(i));

Collections.sort(list);
if(set.contains(list))
anagrams.add(list);

set.add(list);
}

// filter out anagrams
for(String s: domain)
{
word = s.toLowerCase();
list.clear();
for(int i = 0; i < word.length(); i++)
list.add(word.charAt(i));

Collections.sort(list);
if(!anagrams.contains(list))
result.add(s);
}

// output
for(String s: result)
System.out.println(s);
}
}