#include<iostream>
using namespace std;
int ne[100005];
char s[1000005],a[100005];
int main()
{
int n,m,i,j;
scanf("%d%s%d%s",&n,a+1,&m,s+1);
for(i=2,j=0;i<=n;i++){
while(j&&a[i]!=a[j+1])j=ne[j];
if(a[i]==a[j+1])j++;
ne[i]=j;
}
for(i=1,j=0;i<=m;i++){
while(j&&s[i]!=a[j+1])j=ne[j];
if(s[i]==a[j+1])j++;
if(j==n){
printf("%d ",i-n);
j=ne[j];
}
}
return 0;
}