include "stdio.h"
include "string.h"
int main() { int i,j,n,m,slong,xlong,num,number; scanf("%d",&n); char a[n-1][10]; for(i=0;i
scanf("%d",&m);
char b[m-1][10];
for(j=0;j<m;j++)
{
scanf("%s",b[j]);
}
for(j=0;j<m;j++)
{
slong=strlen(b[j]);
number=0;
for(i=0;i<n;i++)
{
num=0;
for(xlong=0;xlong<slong;xlong++)
{
if(b[j][xlong]==a[i][xlong])
{
num++;
}
else
continue;
}
if(num==slong)
number++;
}
printf("%d\n",number);
}
return 0;
}