#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,T,idx,ch[N][26],zc[N],cnt[N],ne[N],q[N],yz[N],t;
void insert(char c[]){
int p=0;
for(int i=0;c[i];i++){
int x=c[i]-'a';
if(!ch[p][x])ch[p][x]=++idx;
p=ch[p][x];
}cnt[p]++;
}
void bfs(){
int h=1,t=0;
for(int i=0;i<26;i++){
if(ch[0][i])q[++t]=ch[0][i];
}
while(h<=t){
int f=q[h];
h++;
for(int i=0;i<26;i++){
if(ch[f][i]){
int c=ch[f][i];
ne[c]=ch[ne[f]][i];
q[++t]=c;
}else{
ch[f][i]=ch[ne[f]][i];
}
}
}
}
int main(){
scanf("%d",&n);
char w[N][173],s[N];
while(n--){
scanf("%s",w[++t]);
insert(w[t]);
}
bfs();
int auv=0,ma=-1;
for(int i=1;i<=idx;i++){
if(cnt[i])zc[i]=++auv;
}
scanf("%s",s);
for(int i=0,j=0;s[i];i++){
int x=s[i]-'a';
while(j&&!ch[j][x])j=ne[j];
if(ch[j][x])j=ch[j][x];
int p=j;
while(p){
if(cnt[p])yz[zc[p]]++;
p=ne[p];
}
}
for(int i=1;i<=t;i++) printf("%d\n",yz[i]);
return 0;
}