  Showing: Handle Score
@Ibrahim Nash 5765
@akhayrutdinov 5111
@mb1973 4993
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
Save The Nation
Easy Accuracy: 22.54% Submissions: 742 Points: 2

Suppose, you are a Army person who is spying on enemy-country. You are on a secret mission to retrieve the top secrets of the enemy. You have succeeded in getting their top secrets. Now what you have to do - you have to send their secrets to your Army headquaters but you can't send the message directly you have to encrypt it, so that no other person can read it.

e.g.
Message: eNEMYwILLaTTACK
Enrypted Form: eYLA NwaC EITK MLT

The way to do it is that the number of rows and the number of columns in the figure (formed from the alphabets of the Message) lie between floor (sqrt(len(message))) and ceil (sqrt(len(message))). It also states that the number of rows is less than or equal to the number of columns, and that the area of rectangle thus formed is minimum. Based on the this criteria, we have to choose a set of values for rows and columns.

For the string haveaniceday, we have floor(sqrt(len(message))) = 3 and ceil(sqrt(len(message))) = 4.

3 * 3 = 9 < len(message) = 15
3 * 4 = 12 = len(message)
4 * 3 = 12 = len(message)
4 * 4 = 16 > len(message)

Out of the 4 possible squares, we can see that #rows = 3 and #columns = 4 is the best fit.
On building the figure, we get

eNEM
YwIL
LaTT
ACK

So, ans : eYLA NwaC EITK MLT

Input:
The first line of input contains an integer denoting the no of test cases. Then T test cases follow. Each test case contains a string s.

Output:
For each test case in a new line print the encrypted text.

Constraints:
1<=T<=100
1<=length of string<=1000

Example:
Input:
3
eNEMYwILLaTTACK
SavetheMines

Output:
eYLA NwaC EITK MLT
Sti ahn vee eMs
Geeyg ErRTh tyeot Eoaf vndi

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:  