#include <bits/stdc++.h>
using namespace std;
#define il inline
#define ull unsigned long long
const int N=2e6+5,Q=37;
int n,len;
int z1[N],z2[N],ans[N];
ull q[N],hsh[N];
char s[N],t[N];
il void Z(int n,char s[]){
z1[1]=n;
for(int i=2,l=0,r=0;i<=n;i++){
if(i<=r)z1[i]=min(z1[i-l+1],r-i+1);
while(i+z1[i]<=n&&s[i+z1[i]]==s[z1[i]+1])++z1[i];
if(i+z1[i]-1>r)l=i,r=i+z1[i]-1;
if(i+z1[i]>n)len=i;
}
z2[n]=n;
for(int i=n-1,l=n+1,r=n+1;i;i--){
if(i>=l)z2[i]=min(z2[n-r+i],i-l+1);
while(i-z2[i]>=0&&s[i-z2[i]]==s[n-z2[i]])++z2[i];
if(i-z2[i]+1<l)l=i-z2[i]+1,r=i;
}
return ;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>(s+1)>>(t+1);
n=strlen(s+1);
q[0]=1;
for(int i=1;i<=n;i++)q[i]=q[i-1]*Q;
for(int i=1;i<=n;i++)hsh[i]=hsh[i-1]*Q+s[i]-'a'+1;
Z(n,s);
// if(n>100)cout<<len<<"\n";
for(int i=1,j=0;i<=n/2;i++)ans[i]=j,z2[i]>=i?j=z2[i]:0;
for(int i=n,j=0;i>n/2;i--)ans[i]=j,i+z1[i]>n?j=z1[i]:0;
for(int i=1;i<=n;i++)s[i]==t[i]?ans[i]=max(ans[i],len_:0;
for(int i=1;i<=n;i++){
int pre=z1[n-i+1],nxt=z2[i];
if(pre+nxt==i-1){
if(pre+1<n-i+1&&t[pre+1]==s[n-nxt])ans[pre+1]=max(ans[pre+1],i);
if(n-nxt>i&&t[n-nxt]==s[pre+1])ans[n-nxt]=max(ans[n-nxt],i);
}else if(pre+nxt==i*2-n-1){
ull h1=hsh[i],h2=hsh[n]-hsh[n-i]*q[i];
h1+=(t[i-nxt]-s[i-nxt])*q[nxt],h2+=(t[i-nxt]-s[i-nxt])*q[i-pre-1];
if(h1==h2)ans[i-nxt]=max(ans[i-nxt],i);
}
}
for(int i=1;i<=n;i++)cout<<ans[i]<<"\n";
return 0;
}