/*一个基础的字符串模拟。
先将句子用get整串读入。然后用sscanf分离出逐个单词进行匹配。
char *p=temp;
while(sscanf(p,"%s",tempkey)>0)
{
p++;
p+=strlen(tempkey);
char *s 则s+a为从第a个字符到s的末尾。
两个过程都用temp和tempkey来实现。
预处理的时候用
if(isalpha(temp[j]))
temp[j]=tolower(temp[j]);
将大写转化成小写。
非字母的部分预处理成空格。
*/
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <ctype.h>
using namespace std;
int main()
{
int n,m;
char a[21][21];
char b[21][71];
char tempkey[100];
char temp[100];
int maxlen[100];
int k=0;
while(scanf("%d%d",&n,&m)==2)
{
int max=0;
for(int i=1; i<101; i++)
maxlen[i]=0;
for(int i=1; i<=n; i++)
scanf("%s",a[i]);
getchar();
for(int i=1; i<=m; i++)
{
gets(b[i]);
strcpy(temp,b[i]);
for(int j=0; temp[j]!='\0'; j++)
{
if(isalpha(temp[j]))
temp[j]=tolower(temp[j]);
else
temp[j]=' ';
}
char *p=temp;
while(sscanf(p,"%s",tempkey)>0)
{
p++;
p+=strlen(tempkey);
for(int j=1; j<=n; j++)
{
if(strcmp(a[j],tempkey)==0)
maxlen[i]++;
}
}
if(maxlen[i]>max)
max=maxlen[i];
}
printf("Excuse Set #%d\n",++k);
for(int i=1; i<=m; i++)
{
if(maxlen[i]==max)
printf("%s\n",b[i]);
}
printf("\n");
}
return 0;
}