Contests | Virtual Contests | Problems | Submit | Runs Status | Rank List | Forum |
Tashj studies the Discrete Mathematics this term. One day, His teacher assigns him a homework: Write a program to compare two legal boolean expression if they are logical equal. You can assume that all the expressions in input data has correct format.
Here is the explanation of the boolean expression.
Input
The first line is a number N followed by a blank line, the number of the test cases. For each test case, there are two lines containing a boolean expressions.
You can assume 1 ≤ N ≤ 100 and the length of each boolean expression will not exceed 100. There is a blank line after each case and no whitespace in any expression.
Output
For each test case, output exactly one line string "The boolean expressions B1 and B2 are logically equal!" if B1 and B2 are logical equivalency.
Else output the string "The boolean expressions B1 and B2 are not logically equal!".
Where B1 and B2 are separately two expressions of each test case in the input.
Sample Input
3 AB+AC A(B+C) (A+C)# A#C# B+C A+D
Sample Output
The boolean expressions AB+AC and A(B+C) are logically equal! The boolean expressions (A+C)# and A#C# are logically equal! The boolean expressions B+C and A+D are not logically equal!
Hint
There may be many parentheses and # in the expression. For example, A##### = A#, ((A))=A.
Any two of the Boolean expressions in the input are logically equal refers to their bool values are equal in any condition, which is the common sense that you learned Discrete Mathematics or other related courses.