BETA

Difficulty Level:

Basic

Total Submissions: 1094 Accuracy:

30.99%

Boolean String Value
     

Given a string consisting of only 0, 1, A, B, C where
A = AND
B = OR
C = XOR
Calculate the value of the string assuming no order of precedence and evaluation is done from left to right.

Input:

The first line of input contains an integer T denoting the number of test cases.
The next T lines contains T strings.

Output:

Print the value of the string assuming no order of precedence and evaluation is done from left to right

Constraints:

1 ≤ T ≤ 100
1 ≤ length(string)<=1000


Examples:
Input : 

1
1A0B1

Output : 1
 

1 AND 0 OR 1 = 1

Input : 
2
1C1B1B0A0
1A0B1

Output : 
0
1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Mohit Gupta_OMG :D

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.