Boolean String Value
Submissions: 7533   Accuracy:

37.27%

  Difficulty: Basic   Marks: 1

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: 
2
1C1B1B0A0
1A0B1

Output: 
0
1

Explanation:
Testcase 1:
1 AND 0 OR 1 = 1

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

Contributor: Mohit Gupta_OMG :D
Author: Mohit Gupta 4


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



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


to report an issue on this page.