String Decryption

0

0 votes
Strings, Easy
Problem

A string S can be encrypted by performing n operations on the string. Here, n is the length of string S. In i th operation, prefix of length i is reversed. For e.g - "edge" can be encrypted by performing 4 operations as: edge -> edge -> dege -> gede -> edeg. Here, in first operation, "edge" was converted to "edge" as "e" was reversed. In second operation , "edge" was converted to "dege" as "ed" was reversed. In third operation "dege" was converted to "gede" as "deg" was reversed. In 4th operation, prefix of length 4, i.e. the entire string is reversed and so our encrypted string becomes "edeg". 

Given the encrypted version of string S, you are given the task to find the original string S.

A prefix of a string S is any leading contiguous part of S. Hence, a prefix of length k of a string S are the first k characters on the left of the string. For e.g. prefix of length 4 of string "carrom" is "carr".

See sample case for better understanding

 

Input format:

First line contains one integer T, deonting the number of testcases.

Next T lines contain a string P, denoting the encrypted version of a string S.

 

Output format:

For each testcase, print the original string S in a new line.

 

Constraints:

1 <= T <= 5

1 <= length of string S <= 100000(1e5)

 

Sample Input
2
nono
rca
Sample Output
noon
car
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In first case, noon is encrypted as: noon -> noon -> onon -> onon -> nono. Hence, original string S is noon.

In second case, car is encrypted as: car -> car -> acr -> rca. Hence, original string S is car.

Contributers:
Editor Image

?