  InterviewBit Academy is now Scaler Academy! # Power of 3

Given a binary string A of size N and an integer matrix B of size Q x 3.

1. For queries of type B[i] = 1, flip the value at index B[i] in A if and only if the value at that index is 0 and return -1.
2. For queries of type B[i] = 0, Return the value of the binary string from index B[i] to B[i] modulo 3.

Note: Rows are numbered from top to bottom and columns are numbered from left to right.

Input Format

``````The first argument given is the string A.
The second argument given is the integer matrix B.
``````

Output Format

``````Return an array of size Q where ith value is answer to ith query.
``````

Constraints

``````1 <= N <= 100000
1 <= Q <= 200000
1 <= B[i], B[i] <= N
B[i] <= B[i]
``````

For Example

``````Input 1:
A = 10010
B = [ [0, 3, 5]
[0, 3, 4]
[1, 2, -1]
[0, 1, 5]
[1, 2, -1]
[0, 1, 4] ]
Output 1:
[2, 1, -1, 2, -1, 1]
``````
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details. 