#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 200010;
char str[N];
int *rank, sa[N];
int wa[N], wb[N], wm[N];
bool comp(int *r, int a, int b, int l)
{
return r[a] == r[b] && r[a+l] == r[b+l];
}
void get_sa(char *r, int *sa, int n, int m)
{
int *x = wa, *y = wb, *t, i, j, p;
for(i = 0; i < m; ++i) wm[i] = 0;
for(i = 0; i < n; ++i) wm[x[i] = r[i]]++;
for(i = 1; i < m; ++i) wm[i] += wm[i-1];
for(i = n-1; i >= 0; --i) sa[--wm[x[i]]] = i;
for(i = 0, j = 1, p = 0; p < n; j <<= 1, m = p) {
for(p = 0, i = n - j; i < n; ++i) y[p++] = i;
for(i = 0; i < n; ++i) if(sa[i] >= j) y[p++] = sa[i] - j;
for(i = 0; i < m; ++i) wm[i] = 0;
for(i = 0; i < n; ++i) wm[x[y[i]]]++;
for(i = 1; i < m; ++i) wm[i] += wm[i-1];
for(i = n-1; i >= 0; --i) sa[--wm[x[y[i]]]] = y[i];
for(t = x, x = y, y = t, i = p = 1, x[sa[0]] = 0; i < n; ++i) {
x[sa[i]] = comp(y, sa[i], sa[i-1], j) ? p-1 : p++;
}
}
rank = x;
}
int main()
{
while(gets(str) != NULL) {
int len = strlen(str);
for(int i = 0; i < len; i++)
str[i + len] = str[i];
str[2 * len] = 0;
get_sa(str, sa, len * 2 + 1, 256);
for(int i = 0; i <= 2 * len; i++)
if(sa[i] < len)
printf("%c", str[sa[i] + len - 1]);
printf("\n");
}
return 0;
}