#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=1000000+10;
char s1[maxn],s2[10100];
int next1[10100];
int h[10100],h1;
int build_next(int len)
{
next1[0]=-1;
for (int i=1;i<len;i++)
{
int j=next1[i-1];
while ((s2[j+1]!=s2[i])&&(j>=0))
{
j=next1[j];
}
if (s2[j+1]==s2[i]) next1[i]=j+1;
else next1[i]=-1;
}
}
int KMP(int len1,int len2)
{
int leng1=0,leng2=0;
while (leng1<len1)
{
if (s1[leng1]==s2[leng2])
{
leng1++;
leng2++;
}
else
{
if (leng2==0) leng1++;
else
{
leng2=next1[leng2-1]+1;
}
}
if (leng2==len2)
{
h1++;
h[h1]=leng1-len2+1;
}
}
}
int main()
{
scanf("%s",s1);
scanf("%s",s2);
int l1=strlen(s1),l2=strlen(s2);
build_next(l2);
KMP(l1,l2);
for (int i=1;i<=h1;i++)
cout << h[i] << endl;
for (int i=0;i<l2;i++)
cout << next1[i]+1 << " ";
return 0;
}
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=1000000+10;
char s1[maxn],s2[10100];
int next1[10100];
int h[10100],h1;
int build_next(int len)
{
next1[0]=-1;
for (int i=1;i<len;i++)
{
int j=next1[i-1];
while ((s2[j+1]!=s2[i])&&(j>=0))
{
j=next1[j];
}
if (s2[j+1]==s2[i]) next1[i]=j+1;
else next1[i]=-1;
}
}
int KMP(int len1,int len2)
{
int leng1=0,leng2=0;
while (leng1<len1)
{
if (s1[leng1]==s2[leng2])
{
leng1++;
leng2++;
}
else
{
if (leng2==0) leng1++;
else
{
leng2=next1[leng2-1]+1;
}
}
if (leng2==len2)
{
h1++;
h[h1]=leng1-len2+1;
}
}
}
int main()
{
scanf("%s",s1);
scanf("%s",s2);
int l1=strlen(s1),l2=strlen(s2);
build_next(l2);
KMP(l1,l2);
for (int i=1;i<=h1;i++)
cout << h[i] << endl;
for (int i=0;i<l2;i++)
cout << next1[i]+1 << " ";
return 0;
}