#include <bits/stdc++.h>
using namespace std;
inline int read(int& x) {
char ch = getchar();
int f = 1; x = 0;
while (ch > '9' || ch < '0') { if (ch == '-')f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); }
return x * f;
}
static auto speedup = []() {ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return nullptr; }();
const int maxn = 1e6 + 7;
int sa[maxn], rk[maxn << 1], oldrk[maxn << 1], cnt[maxn], id[maxn], key1[maxn],c[maxn],x[maxn],y[maxn];
int n, m;
int height[maxn];
char s[maxn];
class SuffixArray {
public:
static void getnlogn2() {
n = strlen(s + 1);
for (int i = 1; i <= n; i++)sa[i] = i, rk[i] = s[i];
for (int w = 1; w < n; w <<= 1) {
std::sort(sa + 1, sa + n + 1, [&](int x, int y) {
return rk[x] == rk[y] ? rk[x + w] < rk[y + w] : rk[x] < rk[y];
});
memmove(oldrk + 1, rk + 1, sizeof(int) * n);
for (int i = 1, p = 0; i <= n; i++) {
if (oldrk[sa[i]] == oldrk[sa[i - 1]] && oldrk[sa[i] + w] == oldrk[sa[i - 1] + w]) {
rk[sa[i]] = p;
}
else {
rk[sa[i]] = ++p;
}
}
}
}
public:
static void _getnlogn() {
int w, p, i;
m = 127;
n = strlen(s + 1);
for (i = 1; i <= n; ++i) ++cnt[rk[i] = s[i]];
for (i = 1; i <= m; ++i) cnt[i] += cnt[i - 1];
for (i = n; i >= 1; --i) sa[cnt[rk[i]]--] = i;
memcpy(oldrk + 1, rk + 1, n * sizeof(int));
for (p = 0, i = 1; i <= n; ++i) {
if (oldrk[sa[i]] == oldrk[sa[i - 1]]) {
rk[sa[i]] = p;
}
else {
rk[sa[i]] = ++p;
}
}
for (w = 1; w < n; w <<= 1, m = n) {
memset(cnt, 0, sizeof(cnt));
memcpy(id + 1, sa + 1,
n * sizeof(int));
for (i = 1; i <= n; ++i) ++cnt[rk[id[i] + w]];
for (i = 1; i <= m; ++i) cnt[i] += cnt[i - 1];
for (i = n; i >= 1; --i) sa[cnt[rk[id[i] + w]]--] = id[i];
memset(cnt, 0, sizeof(cnt));
memcpy(id + 1, sa + 1, n * sizeof(int));
for (i = 1; i <= n; ++i) ++cnt[rk[id[i]]];
for (i = 1; i <= m; ++i) cnt[i] += cnt[i - 1];
for (i = n; i >= 1; --i) sa[cnt[rk[id[i]]]--] = id[i];
memcpy(oldrk + 1, rk + 1, n * sizeof(int));
for (p = 0, i = 1; i <= n; ++i) {
if (oldrk[sa[i]] == oldrk[sa[i - 1]] &&
oldrk[sa[i] + w] == oldrk[sa[i - 1] + w]) {
rk[sa[i]] = p;
}
else {
rk[sa[i]] = ++p;
}
}
}
}
static bool cmp(int x, int y, int w) {
return oldrk[x] == oldrk[y] && oldrk[x + w] == oldrk[y + w];
}
static void getnlogn() {
int w, p, i;
n = strlen(s + 1);
m = 127;
for (i = 1; i <= n; ++i) ++cnt[rk[i] = s[i]];
for (i = 1; i <= m; ++i) cnt[i] += cnt[i - 1];
for (i = n; i >= 1; --i) sa[cnt[rk[i]]--] = i;
for (w = 1;; w <<= 1, m = p) {
for (p = 0, i = n; i > n - w; --i) id[++p] = i;
for (i = 1; i <= n; ++i)
if (sa[i] > w) id[++p] = sa[i] - w;
memset(cnt, 0, sizeof(cnt));
for (i = 1; i <= n; ++i) ++cnt[key1[i] = rk[id[i]]];
for (i = 1; i <= m; ++i) cnt[i] += cnt[i - 1];
for (i = n; i >= 1; --i) sa[cnt[key1[i]]--] = id[i];
memcpy(oldrk + 1, rk + 1, n * sizeof(int));
for (p = 0, i = 1; i <= n; ++i)
rk[sa[i]] = cmp(sa[i], sa[i - 1], w) ? p : ++p;
if (p == n) {
break;
}
}
}
public:
static void get_SA()
{
n = strlen(s + 1);
m = 127;
for (int i = 1; i <= n; ++i) ++c[x[i] = s[i]];
for (int i = 2; i <= m; ++i) c[i] += c[i - 1];
for (int i = n; i >= 1; --i) sa[c[x[i]]--] = i;
for (int k = 1; k <= n; k <<= 1)
{
int num = 0;
for (int i = n - k + 1; i <= n; ++i) y[++num] = i;
for (int i = 1; i <= n; ++i) if (sa[i] > k) y[++num] = sa[i] - k;
for (int i = 1; i <= m; ++i) c[i] = 0;
for (int i = 1; i <= n; ++i) ++c[x[i]];
for (int i = 2; i <= m; ++i) c[i] += c[i - 1];
for (int i = n; i >= 1; --i) sa[c[x[y[i]]]--] = y[i], y[i] = 0;
swap(x, y);
x[sa[1]] = 1; num = 1;
for (int i = 2; i <= n; ++i)
x[sa[i]] = (y[sa[i]] == y[sa[i - 1]] && y[sa[i] + k] == y[sa[i - 1] + k]) ? num : ++num;
if (num == n) break;
m = num;
}
}
public:
static void getHeight() {
int i, k;
for (int i = 1; i <= n; i++)rk[sa[i]] = i;
for (i = 1, k = 0; i <= n; ++i) {
if (rk[i] == 0) continue;
if (k) --k;
while (s[i + k] == s[sa[rk[i] - 1] + k]) ++k;
height[rk[i]] = k;
}
}
};
#include <cstdio>
#include <cstring>
#include <algorithm>
#define F(x) ((x) / 3 + ((x) % 3 == 1 ? 0 : tb))
#define G(x) ((x) < tb ? (x) * 3 + 1 : ((x) - tb) * 3 + 2)
using namespace std;
const int N = 3 * (1e5 + 5);
int wa[N], wb[N], ws[N], wv[N], sa[N];
int rak[N], height[N], cal[N], n;
char s[N], ans[N], s1[N];
int cnt[N];
int c0(int* r, int a, int b) {
return r[a] == r[b] && r[a + 1] == r[b + 1] && r[a + 2] == r[b + 2];
}
int c12(int k, int* r, int a, int b) {
if (k == 2)
return r[a] < r[b] || r[a] == r[b] && c12(1, r, a + 1, b + 1);
return r[a] < r[b] || r[a] == r[b] && wv[a + 1] < wv[b + 1];
}
void Rsort(int* r, int* a, int* b, int n, int m) {
for (int i = 0; i < n; i++) wv[i] = r[a[i]];
for (int i = 0; i < m; i++) ws[i] = 0;
for (int i = 0; i < n; i++) ws[wv[i]]++;
for (int i = 1; i < m; i++) ws[i] += ws[i - 1];
for (int i = n - 1; i >= 0; i--) b[--ws[wv[i]]] = a[i];
}
void dc3(int* r, int* sa, int n, int m) {
int i, j, * rn = r + n, * san = sa + n, ta = 0, tb = (n + 1) / 3, tbc = 0, p;
r[n] = r[n + 1] = 0;
for (i = 0; i < n; i++) if (i % 3 != 0) wa[tbc++] = i;
Rsort(r + 2, wa, wb, tbc, m);
Rsort(r + 1, wb, wa, tbc, m);
Rsort(r, wa, wb, tbc, m);
for (p = 1, rn[F(wb[0])] = 0, i = 1; i < tbc; i++)
rn[F(wb[i])] = c0(r, wb[i - 1], wb[i]) ? p - 1 : p++;
if (p < tbc) dc3(rn, san, tbc, p);
else for (i = 0; i < tbc; i++) san[rn[i]] = i;
for (i = 0; i < tbc; i++) if (san[i] < tb) wb[ta++] = san[i] * 3;
if (n % 3 == 1) wb[ta++] = n - 1;
Rsort(r, wb, wa, ta, m);
for (i = 0; i < tbc; i++) wv[wb[i] = G(san[i])] = i;
for (i = 0, j = 0, p = 0; i < ta && j < tbc; p++)
sa[p] = c12(wb[j] % 3, r, wa[i], wb[j]) ? wa[i++] : wb[j++];
for (; i < ta; p++) sa[p] = wa[i++];
for (; j < tbc; p++) sa[p] = wb[j++];
}
void calheight(int* r, int* sa, int n) {
int i, j, k = 0;
for (i = 1; i <= n; i++) rak[sa[i]] = i;
for (i = 0; i < n; height[rak[i++]] = k)
for (k ? k-- : 0, j = sa[rak[i] - 1]; r[i + k] == r[j + k]; k++);
for (int i = n; i; i--) rak[i] = rak[i - 1];
for (int i = n; i; i--) sa[i]++;
}
int main() {
while (scanf("%s", s + 1) && s[1] != '#') {
n = strlen(s + 1);
for (int i = 1; i <= n; i++)
cal[i] = s[i] - 'a' + 1;
cal[n + 1] = 0;
dc3(cal + 1, sa, n + 1, 30);
calheight(cal + 1, sa, n);
for (int i = 1; i <= n; i++) {
printf("%d ", height[i]);
}puts("");
}
return 0;
}
class SuffixArray {
public:
SuffixArray(int n) {
init(n);
}
void init(int n) {
x.assign(n,0);y.assign(n, 0);c.assign(n, 0);
sa.assign(n, 0); rank.assign(n, 0); height.assign(n, 0);
}
void RSort(int k) {
fill(c.begin(), c.end(), 0);
for (int i = 1; i <= n; i++)y[i] = sa[i];
for (int i = 1; i <= n; i++)c[x[y[i] + k]]++;
for (int i = 1; i <= m; i++)c[i] += c[i - 1];
for (int i = n; i; i--) sa[c[x[y[i] + k]]--] = y[i];
}
void getSa(const char* s,int _n) {
m = 127; n = _n;
int i, k;
for (i = 1; i <= n; i++) c[x[i] = s[i]]++;
for (i = 1; i <= m; i++)c[i] += c[i - 1];
for (i = n; i ; i--) sa[ c[x[i]]--] = i;
for (k = 1; k <= n; k <<= 1) {
RSort(k);
RSort(0);
for (i = 1; i <= n; i++)y[i] = x[i];
for (m = 0, i = 1; i <= n; i++) {
if (y[sa[i]] == y[sa[i - 1]] && y[sa[i] + k] == y[sa[i - 1] + k]) x[sa[i]] = m;
else x[sa[i]] = ++m;
}
if (m == n)break;
}
}
void getHeight(const char* s) {
int i, k;
for (int i = 1; i <= n; i++)rank[sa[i]] = i;
for (i = 1, k = 0; i <= n; ++i) {
if (rank[i] == 0) continue;
if (k) --k;
while (s[i + k] == s[sa[rank[i] - 1] + k]) ++k;
height[rank[i]] = k;
}
}
void out() {
for (int i = 1; i <= n; i++) {
printf("%d ", sa[i]);
}
}
public:
int m;
int n;
vector<int> x, y, c;
vector<int> sa;
vector<int> rank;
vector<int> height;
};
const int maxn = 1e6 + 7;
SuffixArray sa(maxn << 1);