#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
const int M = 1000010;
char P[N], S[M];
int ne[N];
void getNext(int n)
{
for(int q = 1, k = 0; q < n; q++)
{
while(k > 0 && P[k] != P[q])
k = ne[k - 1];
if(P[k] == P[q])
k++;
ne[q] = k;
}
}
void kmp(int n, int m)
{
getNext(n);
for(int i = 0, k = 0; i < m; i++)
{
while(k > 0 && P[k] != S[i])
k = ne[k - 1];
if(P[k] == S[i])
k++;
if(k == n)
{
printf("%d ", i - k + 1);
k = ne[k - 1];
}
}
}
int main()
{
int n, m;
scanf("%d %s%d %s", &n, P, &m, S);
kmp(n, m);
return 0;
}