Brahc in a String Game
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Description
Brahc and Winlere are playing a game with a binary string. Brahc moves first. On each turn:
- Brahc may delete any even-length substring consisting of identical characters.
- Winlere may delete any odd-length substring consisting of identical characters.
When deleting a substring, its left side and right side will merge together. The whole string will not split.
The player who cannot make a move loses.
Before each round starts, they will take the binary string from the previous round's game and choose one contiguous segment to flip all bits in it (turning into and into ).
Given that both Brahc and Winlere play optimally, determine the winner for each round.
Format
Input
The first line contains two integers , the length of the binary string and the number of rounds.
The second line contains numbers, each number is either or , representing the initial binary string.
The next lines, each containing two integers , represent the segment to flip in the current round.
Output
lines, each line contains either or , representing the winner of the corresponding round.
Samples
6 1
1 0 1 1 0 0
5 6
Winlere