#include<bits/stdc++.h>
using namespace std;
char text[1000010],pat[1000010];
void compute_lps(char* pat,int m,int lps[]){
int len=0;
lps[0]=0;
int i=1;
while(i<m){
if(pat[i]==pat[len]){
len++;
lps[i]=len;
i++;
}
else{
if(len!=0) len=lps[len-1];
else{
lps[i]=0;
i++;
}
}
}
}
void kmp(char* text,char* pat){
int n=strlen(text);
int m=strlen(pat); bool flag=true;
int lps[m];
compute_lps(pat,m,lps);
int i=0; //index for text
int j=0; //index for pat
while(i<n){
if(text[i]==pat[j]){
i++; j++;
}
if(j==m){
printf("%d\n",i-j);
j=lps[j-1];
}
else if (i<n && pat[j]!=text[i]){
if(j!=0) j=lps[j-1];
else
i=i+1;
}
}
if(flag) printf("\n");
}
int main()
{
int n;
while(scanf("%d %s %s",&n,pat,text)!=EOF){
kmp(text,pat);
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY2hhciB0ZXh0WzEwMDAwMTBdLHBhdFsxMDAwMDEwXTsKdm9pZCBjb21wdXRlX2xwcyhjaGFyKiBwYXQsaW50IG0saW50IGxwc1tdKXsKICAgIGludCBsZW49MDsKICAgIGxwc1swXT0wOwogICAgaW50IGk9MTsKICAgIHdoaWxlKGk8bSl7CiAgICAgICAgaWYocGF0W2ldPT1wYXRbbGVuXSl7CiAgICAgICAgICAgIGxlbisrOwogICAgICAgICAgICBscHNbaV09bGVuOwogICAgICAgICAgICBpKys7CiAgICAgICAgfQogICAgICAgIGVsc2V7CiAgICAgICAgICAgIGlmKGxlbiE9MCkgbGVuPWxwc1tsZW4tMV07CiAgICAgICAgICAgIGVsc2V7CiAgICAgICAgICAgICAgICBscHNbaV09MDsKICAgICAgICAgICAgICAgIGkrKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQoKdm9pZCBrbXAoY2hhciogdGV4dCxjaGFyKiBwYXQpewogICAgaW50IG49c3RybGVuKHRleHQpOwogICAgaW50IG09c3RybGVuKHBhdCk7IGJvb2wgZmxhZz10cnVlOwogICAgaW50IGxwc1ttXTsKICAgIGNvbXB1dGVfbHBzKHBhdCxtLGxwcyk7CiAgICBpbnQgaT0wOyAvL2luZGV4IGZvciB0ZXh0CiAgICBpbnQgaj0wOyAvL2luZGV4IGZvciBwYXQKICAgIHdoaWxlKGk8bil7CiAgICAgICAgaWYodGV4dFtpXT09cGF0W2pdKXsKICAgICAgICAgICAgaSsrOyBqKys7CiAgICAgICAgfQogICAgICAgIGlmKGo9PW0pewogICAgICAgICAgICBwcmludGYoIiVkXG4iLGktaik7CiAgICAgICAgICAgIGo9bHBzW2otMV07CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYgKGk8biAmJiBwYXRbal0hPXRleHRbaV0pewogICAgICAgICAgICBpZihqIT0wKSBqPWxwc1tqLTFdOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICBpPWkrMTsKICAgICAgICB9CiAgICB9CiAgICBpZihmbGFnKSBwcmludGYoIlxuIik7Cn0KaW50IG1haW4oKQp7CiAgICBpbnQgbjsKICAgIHdoaWxlKHNjYW5mKCIlZCAlcyAlcyIsJm4scGF0LHRleHQpIT1FT0YpewogICAga21wKHRleHQscGF0KTsKICAgIH0KICAgIHJldHVybiAwOwp9Cgo=