1. 

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 409 - Excuses, Excuses!
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=350
*
* @author Evgeni Pavlidis
* @version 1.0, 06/02/2010
*
* Method : Ad hoc
* Status : Accepted
* Runtime: 0.100
*/

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

class Main {

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

int k,e, excuse = 1;
String input;
String[] inputs;
Set<String> keywords = new HashSet<String>();
Set<String> found = new HashSet<String>();


while( (input = reader.readLine()) != null )
{
inputs = input.split(" ");
k = Integer.parseInt(inputs[0]);
e = Integer.parseInt(inputs[1]);

int max = 0;
keywords.clear();
found.clear();

// read keywords
for(int i = 0; i < k; i++)
keywords.add(reader.readLine());

// process excuses
for(int i = 0; i < e; i++)
{
input = reader.readLine();
inputs = input.toLowerCase().split("[^a-z]+");

int current = 0;
for(String s: inputs)
if(keywords.contains(s))
current++;

if(current > max)
{
max = current;
found.clear();
}

if(current == max)
found.add(input);
}

System.out.println("Excuse Set #" + excuse++);
for(String out: found)
System.out.println(out);
System.out.println();
}
}
}