COCI 2007/2008, Contest #3

Task TAJNA

Every evening, little Ivica sends secret messages to little Marica through e-mail. Knowing Ivica's e-letter travels unguarded through the network on its way to Marica's e-mailbox, they have decided to encrypt every message using the following algorithm:

  • Suppose Ivica's message consists of N characters.
  • Ivica must first find a matrix consisting of R rows and C columns such that R ≤ C and R·C = N. If there is more than one such matrix, Ivica chooses the one with the most rows.
  • Ivica writes his message into the matrix in row-major order. In other words, he writes the first segment of the message into the first row, the second segment into the second row and so on.
  • The message he sends to Marica is the matrix read in column-major order.

Marica has grown tired of spending her precious time deciphering Ivica's messages, so you must write a program to do it for her.

Input

The input contains the received message, a string of lowercase letters of the English alphabet (with no spaces).

The number of letters will be between 1 and 100.

Output

Output the original (decrypted) message.

Examples

Input

bok

Output

bok

Input

koaski

Output

kakosi

Input

boudonuimilcbsai

Output

bombonisuuladici

Explanation of Example 3

Ivica wants to send the message "bombonisuuladici" containing 16 letters. He can use a 1×16, 2×8 or 4×4 matrix. Of these, the 4×4 has the most rows. When the message is written into it, the matrix looks like this:

b
o
m
b
o
n
i
s
u
u
l
a
d
i
c
i

All Submissions
Best Solutions


Point Value: 5
Time Limit: 1.00s
Memory Limit: 32M
Added: Jul 30, 2013

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

Using scanf("%s") to read in the string gets AC, but using gets() to read in the string gets WA. Does this mean that there is leading or trailing whitespace in the input files?

Some problems, especially COCI ones, have carriage returns in the data. This is something that your program should account for. It is mentioned in the rules on asking questions: http://wcipeg.com/comments/view#comment3719