Being a judge for a programming contest can be stressful. Judges must prepare challenging, interesting problems and, above all, keep them secret until contest day. Judges often use email to discuss problems, but email is not a safe channel for confidential material: a message can be sent to the wrong recipient by mistake — a student, or worse, a contestant.
To address this, one of the judges, Prof. Nash V. Ruhdney, proposed a way to exchange messages confidentially. Given a message of length n, write it into a rectangle of width k, filling row by row (left to right, top to bottom), and then read it column by column in a chosen order. That column order is the encryption key.
For example:
Message : I am Prof. Nash V. Ruhdney
Key : 3 7 4 1 2 6 5
Grid : I a m P r
o f . N a s
h V . R u
h d n e y * * ('*' is a blank padding cell, not part of the message)
Cipher text : m .e N yIohha.VnrsuPaR f d
The key is a permutation of 1 to k. The j-th value of the key is the rank of column j; columns are read in increasing order of their rank. In the example the ranks are 3 7 4 1 2 6 5, so column 4 (rank 1) is read first, then column 5 (rank 2), then column 1 (rank 3), and so on. Padding cells that lie past the end of the message are skipped.
The professor emails the cipher text while sending the key through another channel, such as a phone call or SMS, to reduce the risk of a leaked email.
Naturally the professor will not encrypt messages by hand. Write a program that performs the encryption for him.
The input contains several test cases. Each test case is given as follows:
The input ends at end of file.
For each message, print its cipher text on its own line.