#include <bits/stdc++.h>
using namespace std;
template <int delta> struct ManacherBase{
private:
static const int maxn=1e5+1;
int r[maxn];
char s[maxn];
int mid,n,i;
public:
ManacherBase():mid(0),i(0),n(1)
{
memset(r,-1,sizeof(int)*maxn);
s[0]='$';
r[0]=0;
}
int get(int pos)
{
pos++;
if(pos<=mid)
return r[pos];
else
return min(r[mid - (pos - mid)], n - pos - 1);
}
void addLetter(char c)
{
s[n]=s[n+1]=c;
while(s[i - r[i] - 1 + delta] != s[i + r[i] + 1])
r[++i] = get(i-1);
r[mid=i]++, n++;
}
int maxPal()
{
return ( n - mid - 1 ) * 2 + 1 - delta;
}
} ;
struct Manacher{
private:
ManacherBase<1> manacherEven;
ManacherBase<0> manacherOdd;
public:
void addLetter(char c)
{
manacherEven.addLetter(c);
manacherOdd.addLetter(c);
}
int maxPal()
{
return max(manacherEven.maxPal(), manacherOdd.maxPal());
}
int getRad(int type,int pos)
{
if(type)
return manacherOdd.get(pos);
else
return manacherEven.get(pos);
}
} ;
main()
{
ios::sync_with_stdio(0);
cin.tie(0);
string t;
while(cin>>t)
{
int n=t.size();
Manacher test;
for(int i=0;i<n;i++)
{
test.addLetter(t[i]);
cout<<"Arrays for string "<<t.substr(0,i+1)<<":"<<endl;
for(int z=0;z<2;z++)
{
for(int j=0;j<=i;j++)
cout<<test.getRad(z,j)<<' ';
cout<<endl;
}
}
cout<<"========================================="<<endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKCnRlbXBsYXRlIDxpbnQgZGVsdGE+IHN0cnVjdCBNYW5hY2hlckJhc2V7CnByaXZhdGU6CgkJc3RhdGljIGNvbnN0IGludCBtYXhuPTFlNSsxOwogICAgICAgIGludCByW21heG5dOwogICAgICAgIGNoYXIgc1ttYXhuXTsKICAgICAgICBpbnQgbWlkLG4saTsKCnB1YmxpYzoKICAgICAgICBNYW5hY2hlckJhc2UoKTptaWQoMCksaSgwKSxuKDEpIAogICAgICAgIHsKICAgICAgICAJbWVtc2V0KHIsLTEsc2l6ZW9mKGludCkqbWF4bik7CiAgICAgICAgCXNbMF09JyQnOwogICAgICAgIAlyWzBdPTA7CiAgICAgICAgfQoKICAgICAgICBpbnQgZ2V0KGludCBwb3MpCiAgICAgICAgewogICAgICAgIAkJcG9zKys7CiAgICAgICAgICAgICAgICBpZihwb3M8PW1pZCkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJbcG9zXTsKICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1pbihyW21pZCAtIChwb3MgLSBtaWQpXSwgbiAtIHBvcyAtIDEpOwogICAgICAgIH0KICAgICAgICAKICAgICAgICB2b2lkIGFkZExldHRlcihjaGFyIGMpCiAgICAgICAgewogICAgICAgICAgICAgICAgc1tuXT1zW24rMV09YzsKICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgd2hpbGUoc1tpIC0gcltpXSAtIDEgKyBkZWx0YV0gIT0gc1tpICsgcltpXSArIDFdKQogICAgICAgICAgICAgICAgICAgICAgICByWysraV0gPSBnZXQoaS0xKTsKICAgICAgICAgICAgICAgIHJbbWlkPWldKyssIG4rKzsKICAgICAgICB9CgogICAgICAgIGludCBtYXhQYWwoKQogICAgICAgIHsKICAgICAgICAgICAgICAgIHJldHVybiAoIG4gLSBtaWQgLSAxICkgKiAyICsgMSAtIGRlbHRhOwogICAgICAgIH0KfSA7CgpzdHJ1Y3QgTWFuYWNoZXJ7CnByaXZhdGU6CiAgICAgICAgTWFuYWNoZXJCYXNlPDE+IG1hbmFjaGVyRXZlbjsKICAgICAgICBNYW5hY2hlckJhc2U8MD4gbWFuYWNoZXJPZGQ7CnB1YmxpYzoKICAgICAgICB2b2lkIGFkZExldHRlcihjaGFyIGMpCiAgICAgICAgewogICAgICAgICAgICAgICAgbWFuYWNoZXJFdmVuLmFkZExldHRlcihjKTsKICAgICAgICAgICAgICAgIG1hbmFjaGVyT2RkLmFkZExldHRlcihjKTsKICAgICAgICB9CgogICAgICAgIGludCBtYXhQYWwoKQogICAgICAgIHsKICAgICAgICAgICAgICAgIHJldHVybiBtYXgobWFuYWNoZXJFdmVuLm1heFBhbCgpLCBtYW5hY2hlck9kZC5tYXhQYWwoKSk7CiAgICAgICAgfQogICAgICAgIGludCBnZXRSYWQoaW50IHR5cGUsaW50IHBvcykKICAgICAgICB7CiAgICAgICAgICAgICAgICBpZih0eXBlKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbWFuYWNoZXJPZGQuZ2V0KHBvcyk7CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtYW5hY2hlckV2ZW4uZ2V0KHBvcyk7CiAgICAgICAgfQp9IDsKCm1haW4oKQogewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBjaW4udGllKDApOwogICAgc3RyaW5nIHQ7CiAgICB3aGlsZShjaW4+PnQpCiAgICB7CiAgICAgICAgaW50IG49dC5zaXplKCk7CiAgICAgICAgTWFuYWNoZXIgdGVzdDsKICAgICAgICBmb3IoaW50IGk9MDtpPG47aSsrKQogICAgICAgIHsKICAgICAgICAgICAgdGVzdC5hZGRMZXR0ZXIodFtpXSk7CiAgICAgICAgICAgIGNvdXQ8PCJBcnJheXMgZm9yIHN0cmluZyAiPDx0LnN1YnN0cigwLGkrMSk8PCI6Ijw8ZW5kbDsKICAgICAgICAgICAgZm9yKGludCB6PTA7ejwyO3orKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZm9yKGludCBqPTA7ajw9aTtqKyspCiAgICAgICAgICAgICAgICAgICAgY291dDw8dGVzdC5nZXRSYWQoeixqKTw8JyAnOwogICAgICAgICAgICAgICAgY291dDw8ZW5kbDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb3V0PDwiPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0iPDxlbmRsOwogICAgfQp9Cgo=