#include
#include
#define N 11
int i,j;
int k;
int ln;
int n;
char s[N*N];
char a[N][N];
void go_right(){
j++;
}
void go_left(){
j--;
}
void go_down(){
i++;
}
void go_up(){
i--;
};
void left_down(){
go_left();
go_down();
}
void right_up(){
go_right();
go_up();
}
void go(){
while(1){
if(j+1 < n){
go_right();a[i][j] = s[k];k++;//右移
if(k == ln +1) return;
}
else{
go_down(); a[i][j] = s[k];k++;
if(k == ln +1) return;
}
while(1){//左下移动
left_down();
if(j >= 0 && i< n) {
a[i][j]=s[k]; k++;
if(k == ln +1) return;
}
else break;
}
j++;i--;//还原一步
if(i+1 < n){
go_down();a[i][j] = s[k];k++;//向下
if(k == ln +1) return;
}
else{
go_right();a[i][j] = s[k];k++;//右移
if(k == ln +1) return;
}
while(1){//右上移动
right_up();
if(i>=0 && j a[i][j]=s[k]; k++;
if(k == ln +1) return;
}
else break;
}
i++;j--;//还原一步
}
}
void print(){
i=j=0;
for(i=0;i for(j=0;j printf("%c",a[i][j]);
printf("\n");
}
}
void Z(char s[]){
ln = strlen(s);
n = (int)sqrt(ln);
k=0;
i=j=0;
a[i][j] = s[k];k++;
go();
print();
return;
}
int main(){
while(scanf("%s",s) != EOF){
Z(s);
}
return 0;
}