Leaderboard
Showing:
Decode It
Easy Accuracy: 26.43% Submissions: 1509 Points: 2

An encoded string S consisting of alphabets(lowercase) and integers(1<=num<=9) is given, the task is to decode it and print the character at the 'K'th position in the string. The pattern in which the strings were encoded were as follows :
original string: jonjonsnowjonjonsnowjonjonsnow
encoded string: jon2snow3

Note: encoded string will always start with an alphabet and end with an number.

Input:
The first line contains a single integer T i.e. the number of test cases. The First line of each test case consists of a encoded string S. The second line of each test case includes of an integer K

Output: 
Print the character at the Kth position in the original string.

Constraints:
1 <= T <= 100
2 <= N <= 30
1 <= K <= N

Examples:
Input:

1
jon2snow3
8

Output:
n

Explanation:
Testcase1:
The given string after decoding it will be as such: jonjonsnowjonjonsnowjonjonsnow. 8th character in string after decoding is: 'n'.

to report an issue on this page.

Editorial

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

Yes

All Submissions

My Submissions:

Login to access your submissions.

Decode It

Output Window