Encrypt the string - 1
Submissions: 6528   Accuracy:

23.48%

  Difficulty: Basic   Marks: 1

Bingu was testing all the strings he had at his place, and found that most of them were prone to vicious attack by Banju, his arch enemy. Bingu decided to encrypt all the strings he had, by the following method. Every substring of identical letters is replaced by a single instance of that letter followed by the number of occurences of that letter. Then, the string thus obtained is further encrypted by reversing it.
 

Input:
The first line contains T, the number of test cases. Then T lines follow, each containing a string S ( |S| <= 1000), consisting of lower case English alphabets

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

 

Constraints
1<=T<=28
Length of each string <=1000



Example:
Input:

2
aabc

aaaaa

Output:
1c1b2a
5a


Explanation:
For first test case
aabc
Step1: a2b1c1
Step2: 1c1b2a

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Vikraman
Author: vikikkdi


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.