1. 
/**
* FWP, Ausgew¤hlte Probleme aus dem ACM Programming Contest, SS10
* Problem: 123 - Searching Quickly
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=3&problem=59&mosmsg=Submission+received+with+ID+8015879
*
* @author Evgeni Pavlidis
* @version 1.0, 06/04/2010
*
* Method : Ad hoc
* Status : Accepted
* Runtime: 0.116
*/

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

class Main {

public static void main(String...args) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

String input;
String[] words;
String element;
int start, end;

Set<String> ignore = new HashSet<String>();
Map<String, List<String>> result = new TreeMap<String, List<String>>();

while(!(input = reader.readLine()).equals("::"))
ignore.add(input.toLowerCase());

while((input = reader.readLine()) != null)
{
input = input.toLowerCase();
words = input.split("\\s+");

start = 0;
for(int w = 0; w < words.length; w++)
{
if(!ignore.contains(words[w]))
{
if(result.get(words[w]) == null)
result.put(words[w], new ArrayList<String>());

element = input.substring(0, start);
element += words[w].toUpperCase();
element += input.substring(start+words[w].length());

result.get(words[w]).add(element);
}

start += words[w].length()+1;
}
}

for(String key: result.keySet())
for(String e : result.get(key))
System.out.println(e);
}
}