Decode It
Submissions: 890   Accuracy:

23.51%

  Difficulty: Easy   Marks: 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'.

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

Contributor: Saksham Ashtputre
Author: saksham0751


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.