constint N = 1000000 + 5; int n, w, m; int rk[N<<1], num[N], cnt[N], id[N<<1]; char s[N]; boolcmp(int x, int y, int w){ return id[x] == id[y] && id[x + w] == id[y + w]; } intmain(){ scanf("%s", (s + 1)); n = strlen(s + 1); m = max(n, 300); for(int i = 1; i <= n; i++) rk[i] = s[i], ++cnt[rk[i]]; for(int i = 1; i <= m; i++) cnt[i] += cnt[i - 1]; for(int i = n; i >= 1; i--) num[cnt[rk[i]]--] = i; for(w = 1; w < n; w <<= 1) { memset(cnt, 0, sizeof(cnt)); int p = 0; for(int i = n; i >= n - w + 1; i--) id[++p] = i; for(int i = 1; i <= n; i++) if(num[i] > w) id[++p] = num[i] - w; for(int i = 1; i <= n; i++) ++cnt[rk[id[i]]]; for(int i = 1; i <= m; i++) cnt[i] += cnt[i - 1]; for(int i = n; i >= 1; i--) num[cnt[rk[id[i]]]--] = id[i], id[i] = rk[i];
m = 0; for(int i = 1; i <= n; i++) rk[num[i]] = cmp(num[i], num[i - 1], w) ? m : ++m; } for(w = 1; w <= n; w++) printf("%d ", num[w]); return0; }