Leaderboard
Showing:
Find the N-th character
Medium Accuracy: 13.26% Submissions: 2689 Points: 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

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.

Find the N-th character

Output Window