#Lutece2313. Sugarii and String
Sugarii and String
Migrated from Lutece 2313 Sugarii and String
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Sugarii is very good at solving string problems. One day, a string suddenly comes to his mind. It is a string with digits and consists of only and . Then he figures out a way to make it longer with the following steps:
- Copy to a new string .
- Reverse every digit in . That is, for every digit in , if it's , change it to ; if it's , change it to .
- Append to the end of .
- Go back to step 1.
For example, if is initially , then it becomes , and then , and then ... The final string can be as long as you want. Sugarii wants to know whether the -th digit of the final string is or .
Input
The first line contains two integers and (, ) — the length of string and the digit Sugarii wants to know.
The second line contains a string , consisting of and .
Output
Print the -th digit of the final string ( or ).
Samples
3 5
110
0
1 10
1
1
Note
In the first sample, the final string is ... , the 5th digit is .
In the second sample, the final string is ... , the 10th digit is .
Resources
电子科技大学第十一届 ACM 趣味程序设计竞赛