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
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.
bruceewayne | 193 |
manvirag982 | 182 |
Core_Ka_Bachha | 180 |
shivam123ahuja | 175 |
Sanjana Singh 1 | 173 |
mr_kksparrow | 433 |
manvirag982 | 398 |
TheHandle | 291 |
rajupraaa1234 | 276 |
Exception_404 | 268 |
blackshadows | 5331 |
Ibrahim Nash | 5219 |
akhayrutdinov | 5111 |
mb1973 | 4929 |
Quandray | 4567 |