Find the N-th character
Submissions: 2334   Accuracy:

13.19%

  Difficulty: Medium   Marks: 4

Given a binary string S . The task is to perform R iterations on string S, in each iteration 0 becomes 01 and 1 becomes 10. Find the Nth character of the string after performing R iterations.

Input:
The first line consists of an integer T i.e number of test cases. The first and only line of each test case contains string S, and two Integers R and N respectively.

Output:
For each test case print the Nth character of string S after Rth iterations in new line.

Constraints: 
1<=T<=100
1<=|string length|<=1000
1<=R<=20
0<=N<|Length of final string|

Example:
Input:

2
101 2 3
11 1 3

Output:
1
0

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

Author: arun03


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.