#P6354. [COCI 2007/2008 #3] TAJNA

[COCI 2007/2008 #3] TAJNA

Description

Use an encryption algorithm.

Let the length of the string be nn. Construct a matrix such that r×c=nr\times c=n, and under the condition rcr\le c, make rr as large as possible.

Then fill the given plaintext into this r×cr\times c matrix in the order from top to bottom, left to right.

The ciphertext is obtained by outputting the matrix in the order from left to right, top to bottom, forming a string.

Given the plaintext, output the ciphertext.

Input Format

One line with a string, representing the plaintext.

Output Format

One line with a string, representing the ciphertext.

bok
bok
koaski
kakosi
boudonuimilcbsai
bombonisuuladici

Hint

Explanation of Sample 3

There are 1616 characters in total. For the matrix dimensions, you can choose 1×161\times 16, 2×82\times 8, and 4×44\times 4. Since rr should be as large as possible, choose 4×44\times 4.

Then fill the matrix. The result of filling is shown in the figure above.

Finally, output each character from left to right, top to bottom.

Constraints

For 100%100\% of the testdata, the input string contains only lowercase letters, and its length does not exceed 100100.

Note

This problem is translated from COCI2007-2008 CONTEST #3 T3 TAJNA

Translated by ChatGPT 5