CF923D Picking Strings
Description
Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times:
- A BC
- B AC
- C AB
- AAA  empty string
Note that a substring is one or more consecutive characters. For given queries, determine whether it is possible to obtain the target string from source.
Input Format
The first line contains a string $ S $ ( $ 1
Output Format
Print a string of $ Q $ characters, where the $ i $ -th character is '1' if the answer to the $ i $ -th query is positive, and '0' otherwise.
Explanation/Hint
In the first query we can achieve the result, for instance, by using transitions .
The third query asks for changing AAB to A — but in this case we are not able to get rid of the character 'B'.