Find the N-th character
Submissions: 2143   Accuracy:

13.55%

  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


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

to report an issue on this page.